Re: MIP from BMP Images [message #76811] |
Thu, 07 July 2011 10:40  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Paulo Penteado writes:
>> ᅵ ᅵ ᅵ(b). is there anything that is causing the 'image' to change its
>> array format? I haven't declared 'image' as an array.
>
> IDL does not even have variable declarations. read_bmp is just giving
> you the image, with the dimensions it had in the file. If the file is
> a 24-bit RGB, then the result is color interleaved (color is the first
> dimension).
The news is even worse than this, because if your
images really are true-color images, then there is
no "intensity" in them, only color information.
Thus, is will be impossible (as far as I know) to
create a MIP image out of this lot. :-(
Cheers,
David
P.S. Maybe you can make gray-scale images
out of the image you have. I'm not sure this
is really kosher, but it may solve your
problem.
http:/www.idlcoyote.com/ip_tips/color2gray.html
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thue. ("Perhaps thos speakest truth.")
|
|
|
Re: MIP from BMP Images [message #76812 is a reply to message #76811] |
Thu, 07 July 2011 10:12   |
penteado
Messages: 866 Registered: February 2018
|
Senior Member Administrator |
|
|
On Jul 7, 12:15 pm, M R <manisha....@gmail.com> wrote:
> 1. for the following command>IDL print, file
>
> the output contained the list of images being loaded. But I have
> noticed that even though the images are stored in an ascending order
> in the folder, the output is not so. Instead the output is
> 0,1,10,100,101,102........12,120,121,.......13,130,131 and so on.
> Is this because the files are not being loaded in an ascending manner
> or it's just the output that is not in an order?
The order you see in the file array is the order file_search gave you.
By default, it sorts alphabetically, to ensure a consistent result
across platforms. If you use the nosort keyword to file_search, they
will be in whatever order the OS decides to use. If you want a
particular order, then you probably will have to first sort the array
in the order you want.
>
> 2. with >IDL help, image the output is
>
> image byte =array [3,2216,1254].
>
> (a). why is there a 3 in the first position?
The array image has whatever dimensions the image in the file had. In
this case, it looks like the file is an RGB image with the first
dimension being the channel, and each channel being 2216x1254.
> The array should be
> in the format of [2216, 1254, i] where i can be anything from 0-255.
This sentence makes no sense to me.
> (b). is there anything that is causing the 'image' to change its
> array format? I haven't declared 'image' as an array.
IDL does not even have variable declarations. read_bmp is just giving
you the image, with the dimensions it had in the file. If the file is
a 24-bit RGB, then the result is color interleaved (color is the first
dimension).
|
|
|
Re: MIP from BMP Images [message #76815 is a reply to message #76812] |
Thu, 07 July 2011 08:15   |
M R
Messages: 19 Registered: July 2011
|
Junior Member |
|
|
On Jul 6, 6:18 pm, Paulo Penteado <pp.pente...@gmail.com> wrote:
> On Jul 6, 5:40 pm, M R <manisha....@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
>> On Jul 6, 2:22 pm, David Fanning <n...@dfanning.com> wrote:
>
>>> M R writes:
>>>> Thank you for the feedback. I have tried the following. The errors are
>>>> pasted below.
>
>>>> arm=bytarr(2216,1254,255,/nozero)
>>>> for i=0,254 do begin
>>>> file=file_search('filepath.bmp')
>>>> image=read_image(file[i])
>>>> arm=image[i]
>>>> end
>>>> TV,MAX(arm,dimension=3)
>>>> end
>
>>>> Errors
>>>> % Attempt to subscript FILE with I is out of range.
>
>>>> Why does it say file[i] is out of range?Should I declare file as
>>>> another array to store the images?
>
>>> You might want to count how many files you actually
>>> found with your File_Search statement. I'm going to
>>> guess no more than 1, and probably zero. You can use
>>> a COUNT keyword to return the file count to you.
>
>>> You probably want something like this:
>
>>> files = file_search('*.bmp', COUNT=count)
>>> for j=0,count-1 do ....
>
>>> When you put an image into your arm array, you will
>>> want something like this:
>
>>> arm[*,*,j] = image
>
>>> But, believe me when I tell you, you are going to want
>>> a MUCH smaller array! ;-)
>
>>> Cheers,
>
>>> david
>
>>> --
>>> David Fanning, Ph.D.
>>> Fanning Software Consulting, Inc.
>>> Coyote's Guide to IDL Programming:http://www.dfanning.com/
>>> Sepore ma de ni thue. ("Perhaps thos speakest truth.")
>
>> For the following, I get
>
>> file=file_search('filepath....\*.bmp',COUNT=count)
>
>> arm=bytarr(2216,1254,count,/nozero)
>
>> for i=0,count-1 do begin
>
>> image=read_image(file[i])
>
>> arm[*,*,i] = image
>
>> end
>
>> TV,MAX(arm,dimension=3)
>
>> end
>
>> % Array subscript for ARM must have same size as source expression.
>> Is it not picking up the images in an order? Should I try with smaller
>> size images and a fewer number of images?Thank you!
>
> This indicates that at the point the program stopped the dimensions of
> image were not 2216x1254. You can easily find what they were with a
> 'help,image' when execution is halted at that point.
Thank you Paulo! I have tried that and noticed two things.
1. for the following command
> IDL print, file
the output contained the list of images being loaded. But I have
noticed that even though the images are stored in an ascending order
in the folder, the output is not so. Instead the output is
0,1,10,100,101,102........12,120,121,.......13,130,131 and so on.
Is this because the files are not being loaded in an ascending manner
or it's just the output that is not in an order?
2. with >IDL help, image the output is
image byte =array [3,2216,1254].
(a). why is there a 3 in the first position? The array should be
in the format of [2216, 1254, i] where i can be anything from 0-255.
(b). is there anything that is causing the 'image' to change its
array format? I haven't declared 'image' as an array.
Thank you!
|
|
|
|
|
Re: MIP from BMP Images [message #76820 is a reply to message #76817] |
Wed, 06 July 2011 16:04   |
R.G.Stockwell
Messages: 163 Registered: October 2004
|
Senior Member |
|
|
"M R" wrote in message
news:86356112-451a-4e39-bbee-f6a652440655@5g2000yqb.googlegr oups.com...
...
> arm=bytarr(2216,1254,255,/nozero)
> for i=0,254 do begin
> file=file_search('filepath.bmp')
> image=read_image(file[i])
> arm=image[i]
> end
> TV,MAX(arm,dimension=3)
> end
do not call file_search inside the loop. Also, one often uses file_search
with wildcards.
> % Attempt to subscript FILE with I is out of range.
how could file_search possible return more than one file here, you have an
explicit full filename. To quote the Highlander, there can be only one.
|
|
|
Re: MIP from BMP Images [message #76823 is a reply to message #76820] |
Wed, 06 July 2011 16:18   |
penteado
Messages: 866 Registered: February 2018
|
Senior Member Administrator |
|
|
On Jul 6, 5:40 pm, M R <manisha....@gmail.com> wrote:
> On Jul 6, 2:22 pm, David Fanning <n...@dfanning.com> wrote:
>
>
>
>
>
>
>
>
>
>> M R writes:
>>> Thank you for the feedback. I have tried the following. The errors are
>>> pasted below.
>
>>> arm=bytarr(2216,1254,255,/nozero)
>>> for i=0,254 do begin
>>> file=file_search('filepath.bmp')
>>> image=read_image(file[i])
>>> arm=image[i]
>>> end
>>> TV,MAX(arm,dimension=3)
>>> end
>
>>> Errors
>>> % Attempt to subscript FILE with I is out of range.
>
>>> Why does it say file[i] is out of range?Should I declare file as
>>> another array to store the images?
>
>> You might want to count how many files you actually
>> found with your File_Search statement. I'm going to
>> guess no more than 1, and probably zero. You can use
>> a COUNT keyword to return the file count to you.
>
>> You probably want something like this:
>
>> files = file_search('*.bmp', COUNT=count)
>> for j=0,count-1 do ....
>
>> When you put an image into your arm array, you will
>> want something like this:
>
>> arm[*,*,j] = image
>
>> But, believe me when I tell you, you are going to want
>> a MUCH smaller array! ;-)
>
>> Cheers,
>
>> david
>
>> --
>> David Fanning, Ph.D.
>> Fanning Software Consulting, Inc.
>> Coyote's Guide to IDL Programming:http://www.dfanning.com/
>> Sepore ma de ni thue. ("Perhaps thos speakest truth.")
>
> For the following, I get
>
> file=file_search('filepath....\*.bmp',COUNT=count)
>
> arm=bytarr(2216,1254,count,/nozero)
>
> for i=0,count-1 do begin
>
> image=read_image(file[i])
>
> arm[*,*,i] = image
>
> end
>
> TV,MAX(arm,dimension=3)
>
> end
>
> % Array subscript for ARM must have same size as source expression.
> Is it not picking up the images in an order? Should I try with smaller
> size images and a fewer number of images?Thank you!
This indicates that at the point the program stopped the dimensions of
image were not 2216x1254. You can easily find what they were with a
'help,image' when execution is halted at that point.
|
|
|
Re: MIP from BMP Images [message #76825 is a reply to message #76820] |
Wed, 06 July 2011 13:40   |
M R
Messages: 19 Registered: July 2011
|
Junior Member |
|
|
On Jul 6, 2:22 pm, David Fanning <n...@dfanning.com> wrote:
> M R writes:
>> Thank you for the feedback. I have tried the following. The errors are
>> pasted below.
>
>> arm=bytarr(2216,1254,255,/nozero)
>> for i=0,254 do begin
>> file=file_search('filepath.bmp')
>> image=read_image(file[i])
>> arm=image[i]
>> end
>> TV,MAX(arm,dimension=3)
>> end
>
>> Errors
>> % Attempt to subscript FILE with I is out of range.
>
>> Why does it say file[i] is out of range?Should I declare file as
>> another array to store the images?
>
> You might want to count how many files you actually
> found with your File_Search statement. I'm going to
> guess no more than 1, and probably zero. You can use
> a COUNT keyword to return the file count to you.
>
> You probably want something like this:
>
> files = file_search('*.bmp', COUNT=count)
> for j=0,count-1 do ....
>
> When you put an image into your arm array, you will
> want something like this:
>
> arm[*,*,j] = image
>
> But, believe me when I tell you, you are going to want
> a MUCH smaller array! ;-)
>
> Cheers,
>
> david
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thue. ("Perhaps thos speakest truth.")
For the following, I get
file=file_search('filepath....\*.bmp',COUNT=count)
arm=bytarr(2216,1254,count,/nozero)
for i=0,count-1 do begin
image=read_image(file[i])
arm[*,*,i] = image
end
TV,MAX(arm,dimension=3)
end
% Array subscript for ARM must have same size as source expression.
Is it not picking up the images in an order? Should I try with smaller
size images and a fewer number of images?Thank you!
|
|
|
Re: MIP from BMP Images [message #76826 is a reply to message #76825] |
Wed, 06 July 2011 12:41   |
M R
Messages: 19 Registered: July 2011
|
Junior Member |
|
|
On Jul 6, 2:22 pm, David Fanning <n...@dfanning.com> wrote:
> M R writes:
>> Thank you for the feedback. I have tried the following. The errors are
>> pasted below.
>
>> arm=bytarr(2216,1254,255,/nozero)
>> for i=0,254 do begin
>> file=file_search('filepath.bmp')
>> image=read_image(file[i])
>> arm=image[i]
>> end
>> TV,MAX(arm,dimension=3)
>> end
>
>> Errors
>> % Attempt to subscript FILE with I is out of range.
>
>> Why does it say file[i] is out of range?Should I declare file as
>> another array to store the images?
>
> You might want to count how many files you actually
> found with your File_Search statement. I'm going to
> guess no more than 1, and probably zero. You can use
> a COUNT keyword to return the file count to you.
>
> You probably want something like this:
>
> files = file_search('*.bmp', COUNT=count)
> for j=0,count-1 do ....
>
> When you put an image into your arm array, you will
> want something like this:
>
> arm[*,*,j] = image
>
> But, believe me when I tell you, you are going to want
> a MUCH smaller array! ;-)
>
> Cheers,
>
> david
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thue. ("Perhaps thos speakest truth.")
I am wishing desperately to work with a smaller array but since the
images are from an MRI scanner in the form of BMP, they are occupying
a gigantic amount of space! Will try what you have suggested and I am
hoping it will work.If it doesn't then I might break down the images
into smaller data sets and build the MIP by parts and stitch the parts
together (long shot!) Thank you!
|
|
|
Re: MIP from BMP Images [message #76827 is a reply to message #76826] |
Wed, 06 July 2011 12:35   |
M R
Messages: 19 Registered: July 2011
|
Junior Member |
|
|
On Jul 6, 2:22 pm, David Fanning <n...@dfanning.com> wrote:
> M R writes:
>> Thank you for the feedback. I have tried the following. The errors are
>> pasted below.
>
>> arm=bytarr(2216,1254,255,/nozero)
>> for i=0,254 do begin
>> file=file_search('filepath.bmp')
>> image=read_image(file[i])
>> arm=image[i]
>> end
>> TV,MAX(arm,dimension=3)
>> end
>
>> Errors
>> % Attempt to subscript FILE with I is out of range.
>
>> Why does it say file[i] is out of range?Should I declare file as
>> another array to store the images?
>
> You might want to count how many files you actually
> found with your File_Search statement. I'm going to
> guess no more than 1, and probably zero. You can use
> a COUNT keyword to return the file count to you.
>
> You probably want something like this:
>
> files = file_search('*.bmp', COUNT=count)
> for j=0,count-1 do ....
>
> When you put an image into your arm array, you will
> want something like this:
>
> arm[*,*,j] = image
>
> But, believe me when I tell you, you are going to want
> a MUCH smaller array! ;-)
>
> Cheers,
>
> david
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thue. ("Perhaps thos speakest truth.")
I am desperately wishing to deal with a smaller array but
unfortunately the images are from an MRI scanner in BMP format.
Without losing much detail, I tried Jpeg but was loosing a lot of
finer details in the images. But will definitely try this and see how
it works. Thank you!
|
|
|
Re: MIP from BMP Images [message #76828 is a reply to message #76827] |
Wed, 06 July 2011 12:22   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
M R writes:
> Thank you for the feedback. I have tried the following. The errors are
> pasted below.
>
> arm=bytarr(2216,1254,255,/nozero)
> for i=0,254 do begin
> file=file_search('filepath.bmp')
> image=read_image(file[i])
> arm=image[i]
> end
> TV,MAX(arm,dimension=3)
> end
>
> Errors
> % Attempt to subscript FILE with I is out of range.
>
> Why does it say file[i] is out of range?Should I declare file as
> another array to store the images?
You might want to count how many files you actually
found with your File_Search statement. I'm going to
guess no more than 1, and probably zero. You can use
a COUNT keyword to return the file count to you.
You probably want something like this:
files = file_search('*.bmp', COUNT=count)
for j=0,count-1 do ....
When you put an image into your arm array, you will
want something like this:
arm[*,*,j] = image
But, believe me when I tell you, you are going to want
a MUCH smaller array! ;-)
Cheers,
david
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thue. ("Perhaps thos speakest truth.")
|
|
|
Re: MIP from BMP Images [message #76829 is a reply to message #76828] |
Wed, 06 July 2011 11:57   |
M R
Messages: 19 Registered: July 2011
|
Junior Member |
|
|
On Jul 6, 11:57 am, Wox <s...@nomail.com> wrote:
> On Wed, 6 Jul 2011 09:10:27 -0700 (PDT), M R <manisha....@gmail.com>
> wrote:
>
>> I am fairly new to IDl and trying to learn.
>> I have a series of 255 bitmap images in a folder.I have to create a
>> rotating MIP from these images. Each image is of the size 2216 X 1254.
>> I cannot use read_bmp (as mentioned in IDL Help 8.1 as each line
>> should be evenly divisible by 4). I am trying to create a 3D array of
>> the size (3000 X 3000 X 500) in case the image size and number of
>> images change for each data set. How should I go about addressing this
>> issue of loading images into IDL? I will be using FOR loop to build
>> the MIP. I haven't yet thought about rotating the MIP. Any help,
>> suggestions, advice is greatly appreciated. Thank you!
>
> Not an expert in this but:
>
> 1. read_bmp works for me:
> IDL> write_bmp,'c:/tst.bmp',bytarr(2216,1254)
> IDL> help,read_bmp('c:/tst.bmp')
> <Expression> BYTE = Array[2216, 1254]
>
> 2. Use read_bmp in a loop just as you suggested. If you run into
> memory issues, use CONGRID or REBIN to make the images smaller before
> adding them to the stack. If all images are of the same dimension in 1
> dataset, why do you need to convert them to 3000x3000?
>
> 3. Checkout XVOLUME_ROTATE+XVOLUME for MIP. Maybe also iVolume and
> xslicer helps?
>
> I must say I was never convinced by IDL's 3D rendering/handling. I
> think products like Avizo and VGStudio MAX are more appropriate.
Thank you for the feedback. I have tried the following. The errors are
pasted below.
arm=bytarr(2216,1254,255,/nozero)
for i=0,254 do begin
file=file_search('filepath.bmp')
image=read_image(file[i])
arm=image[i]
end
TV,MAX(arm,dimension=3)
end
Errors
% Attempt to subscript FILE with I is out of range.
I was changing the array dimensions to 3000X3000X500 to accommodate
data sets of different sizes. Yes, I did run into problems with that
and stuck to 2216 X 1254 X 255.
Why does it say file[i] is out of range?Should I declare file as
another array to store the images?
|
|
|
Re: MIP from BMP Images [message #76832 is a reply to message #76829] |
Wed, 06 July 2011 09:57   |
Wout De Nolf
Messages: 194 Registered: October 2008
|
Senior Member |
|
|
On Wed, 6 Jul 2011 09:10:27 -0700 (PDT), M R <manisha.rkp@gmail.com>
wrote:
> I am fairly new to IDl and trying to learn.
> I have a series of 255 bitmap images in a folder.I have to create a
> rotating MIP from these images. Each image is of the size 2216 X 1254.
> I cannot use read_bmp (as mentioned in IDL Help 8.1 as each line
> should be evenly divisible by 4). I am trying to create a 3D array of
> the size (3000 X 3000 X 500) in case the image size and number of
> images change for each data set. How should I go about addressing this
> issue of loading images into IDL? I will be using FOR loop to build
> the MIP. I haven't yet thought about rotating the MIP. Any help,
> suggestions, advice is greatly appreciated. Thank you!
Not an expert in this but:
1. read_bmp works for me:
IDL> write_bmp,'c:/tst.bmp',bytarr(2216,1254)
IDL> help,read_bmp('c:/tst.bmp')
<Expression> BYTE = Array[2216, 1254]
2. Use read_bmp in a loop just as you suggested. If you run into
memory issues, use CONGRID or REBIN to make the images smaller before
adding them to the stack. If all images are of the same dimension in 1
dataset, why do you need to convert them to 3000x3000?
3. Checkout XVOLUME_ROTATE+XVOLUME for MIP. Maybe also iVolume and
xslicer helps?
I must say I was never convinced by IDL's 3D rendering/handling. I
think products like Avizo and VGStudio MAX are more appropriate.
|
|
|
|
Re: MIP from BMP Images [message #76898 is a reply to message #76811] |
Fri, 08 July 2011 08:13  |
M R
Messages: 19 Registered: July 2011
|
Junior Member |
|
|
I hope I am making some kind of progress here. I have the following
code and I (fortunately) do not get any errors and of course the
output is in the form of a blank black pop out screen (I am being too
optimistic) and think atleast the program works! Below is the code
fil = file_search('filepath*.bmp',COUNT = count)
imag=read_bmp(fil[0])
s=size(imag)
arm = bytarr (s[1],s[2],count,/nozero)
for i=0, count-1 do begin
image = read_bmp(fil[i])
arm[*,*,i]=image[*,*]
end
TV,MAX (arm, dimension = 3)
end
(i). imag, arm, image array sizes do not match. They are
IDL> help, arm
ARM BYTE = Array[3, 2216, 256]
IDL> help, imag
IMAG BYTE = Array[3, 2216, 1254]
IDL> help, image
IMAGE BYTE = Array[3, 2216, 1254]
Does anyone feel that this mismatch between the array sizes is
creating the blank black pop out screen instead of an image?
(ii).
> IDL print, fil shows that the images are being loaded in an alphabetical manner. Not in an ascending order. I have used sort command, but the system took more 12 hrs and hasn't yet reported an output yet. Is there something I am overlooking?
Thank you all again for your help!
|
|
|