X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 29 Apr 2014 12:07 AM by  anon
BSQ file using Congrid returning only first band values
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
29 Apr 2014 12:07 AM
    Hi All, I am having an issue when using congrid on a 3 band bsq image file, where the output from the congrid is still 3 bands, the values for all the bands are only from the 1st band. What I am trying to do is replicate the ENVI (I have v4.8) resize function programmatically in IDL (v8.01), which I have tested with this same bsq file and works correctly, but am getting the error as mentioned with congrid. My process in IDL is that I am reading 3 separate ascii files (corresponding to the 3 bands) into an array (3x 7000pix by 7000pix, so the array is 7000x21000), then saving the array as a bsq file with ENVI_WRITE_ENVI_FILE. Next, I am then performing the congrid on the array and then saving the resized array in another bsq file. My code example is: red_data = READ_ASCII(redfile, DATA_START = 6, DELIMETER = string (' '), COUNT = nl) rnd_data = [red_data.(0)] mir_data = READ_ASCII(mirfile, DATA_START = 6, DELIMETER = string (' ')) rnd_data = [[rnd_data], [mir_data.(0)]] tir_data = READ_ASCII(tirfile, DATA_START = 6, DELIMETER = string (' ')) rnd_data = [[rnd_data], [tir_data.(0)]] ENVI_WRITE_ENVI_FILE, rnd_data, BNAMES = ['Red', 'MIR', 'TIR'], FILE_TYPE = 0, INTERLEAVE = 0, NB = 3, NS = ns, NL = nl, OUT_DT = 4, OUT_NAME = ofname res_file = CONGRID(rnd_data, 175, 175, /INTERP) ENVI_WRITE_ENVI_FILE, res_file, BNAMES = ['Red', 'MIR', 'TIR'], FILE_TYPE = 0, INTERLEAVE = 0, NB = 3, NS = nrs, NL = nrl, OUT_DT = 4, OUT_NAME = ofrname As mentioned, the output creates a 3 band bsq file, but with all the values from the 1st band of the array. I cannot see where I am going wrong with my code and would very much appreciate if you could point out where the code is incorrect. Alternatively, if there is a better way of performing the operation, I would much appreciate advice (the read ascii steps each take 4 minutes, so the whole routine is lengthy and I would like to speed it up a bit). Many thanks in advance Simon

    Deleted User



    New Member


    Posts:
    New Member


    --
    07 May 2014 02:16 AM
    At first look, your BSQ array, i.e. a multi band image, is not a BSQ array. It is still a 2D array. I'll use 3x3 arrays as an example. red_data = fix(randomu(sd,3,3)*256) mir_data = fix(randomu(sd,3,3)*256) tir_data = fix(randomu(sd,3,3)*256) print, size(red_data, /dimensions) 3 3 rnd_data = [red_data] print, size(rnd_data, /dimensions) 3 3 rnd_data = [[rnd_data], [mir_data]] print, size(rnd_data, /dimensions) 3 6 rnd_data = [[rnd_data], [tir_data]] print, size(rnd_data, /dimensions) 3 9 This isn't a multi band array, it is still a 2D image consisting of 3 cols and 9 rows. ENVI will still interpret this as 3 band image, as the array gets written out as a 1D file and ENVI will simply reform it to be a 3D array. Try: rnd_data = reform(rnd_data, 3,3,3) print, size(rnd_data, /dimensions) 3 3 3 or rnd_data = [[[red_data]],[[mir_data]],[[tir_data]]] print, size(rnd_data, /dimensions) 3 3 3 This is now a multi band array consisting of 3 columns by 3 rows by 3 bands. The line 'res_file = CONGRID(rnd_data, 175, 175, /INTERP)' won't work with a 3D array, unless you specify the z axis. Alternatively create a loop and apply congrid to each band separately. Hope that helps Josh

    Deleted User



    New Member


    Posts:
    New Member


    --
    14 May 2014 08:27 AM
    Hi Josh, Thanks for the help. I had previously tried to apply the congrid individually, but was getting errors (turns out was stupid spelling mistake). I am now getting it to work. I am interested in running it through as a multi band array, and will give that a try as well. Many thanks again. Simon
    You are not authorized to post a reply.