Images [message #91954] |
Tue, 22 September 2015 15:10  |
joyrles1996
Messages: 27 Registered: August 2015
|
Junior Member |
|
|
I have many images of dimensions [512,512], 320 images.
I want to take a piece of each([1,512] and I want to join the images' pieces in a only array, for example [320,512].
help me, please.
thanks.
|
|
|
Re: Images [message #91955 is a reply to message #91954] |
Tue, 22 September 2015 15:42   |
penteado
Messages: 866 Registered: February 2018
|
Senior Member Administrator |
|
|
On Tuesday, September 22, 2015 at 7:10:50 PM UTC-3, Joyrles Fernandes wrote:
> I have many images of dimensions [512,512], 320 images.
> I want to take a piece of each([1,512] and I want to join the images' pieces in a only array, for example [320,512].
The answer depends on what you mean by "having images". Are the images in files? One file per image? Guessing the answer to both questions is yes, and that you have an array with the 320 file names (let's call it filenames), one possible way might be something like
compound_image=dblarr(320,512) ;guessing that your image data are doubles
for i=0,319 do compound_image[i,*]=(read_image(filenames[i]))[1,*]
|
|
|
Re: Images [message #91960 is a reply to message #91955] |
Wed, 23 September 2015 08:06  |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
On 09/22/15 18:42, Paulo Penteado wrote:
> On Tuesday, September 22, 2015 at 7:10:50 PM UTC-3, Joyrles Fernandes wrote:
>> I have many images of dimensions [512,512], 320 images.
>> I want to take a piece of each([1,512] and I want to join the
>> images'pieces in a only array, for example [320,512].
>
> The answer depends on what you mean by "having images". Are the
> imagesin files? One file per image? Guessing the answer to both questions is
> yes, and that you have an array with the 320 file names (let's call it
> filenames), one possible way might be something like
>
> compound_image=dblarr(320,512) ;guessing that your image data are doubles
> for i=0,319 do compound_image[i,*]=(read_image(filenames[i]))[1,*]
Or, if we assume the image data is in bytes:
image_stack = bytarr(512,512,320)
help, image_stack
IMAGE_STACK BYTE = Array[512, 512, 320]
for i = 0,319 do image_stack[*,*,i] = read_image(filenames[i])
That works out to < 100MB by my reckoning. And < 300MB if there are RGB
channels as well. Doesn't seem too large(?).
Then, also assuming the indexing order is correct, any slice required
can be selected:
slice_index = 6 ; pick the 6'th longitudinal slice
image_slice = transpose(image_stack[slice_index,*,*],[2,1,0])
help, image_slice
IMAGE_SLICE BYTE = Array[320, 512]
slice_index = 100 ; pick the 100'th transverse slice
image_slice = transpose(image_stack[*,slice_index,*],[2,0,1])
help, image_slice
IMAGE_SLICE BYTE = Array[320, 512]
cheers,
paulv
|
|
|