Re: Maximum intensity projection (MIP) [message #53456] |
Thu, 12 April 2007 06:52 |
Paolo Grigis
Messages: 171 Registered: December 2003
|
Senior Member |
|
|
Anne Martel wrote:
> Steve,
>
> For a mip in the x-y plane you just need to do
>
> mipIm=data[*,*,0]
> for i = 1,79 do mipIm = mipIm > data[*,*,i]
You can avoid the loop using the dimension keyword of max:
mipIm=max(data,dimension=3)
Ciao,
Paolo
>
> I've pasted my mip routine below - it gives you more control over the
> orientation and slices to use. I posted an interactive GUI version on
> the IDL website a few years ago - I think it was called xmip and it
> should still be there,
>
> Anne
>
> $Id: mip.pro $
> ;
> ;+
> ; NAME:
> ; MIP
> ;
> ; PURPOSE:
> ; Function to return the max (or min) intensity projection of
> ; an array of images.
>
> ; CATEGORY:
> ;
> ;
> ; CALLING SEQUENCE:
> ; myMipImage=MIP(image)
> ;
> ; INPUTS:
> ; image - raw image image - must be a 3D array
>
> ; KEYWORD PARAMETERS:
>
> ; ORIENTATION: This gives the orientation of the mip image.
> ; default = 2 -ie mip generated using images (*,*,i)
> ;
>
> can also have 0 or 1
> ; MAXIMUM: Generates max intensity projection image (the default)
> ; MINIMUM: Generates min intensity projection image
> ; X_LOWER, X_UPPER: extent of array in X direction with which to
> generate the mip.
> ; Only has an effect if orientation=0
> ; Y_LOWER, Y_UPPER: extent of array in Y direction with which to
> generate the mip.
> ; Only has an effect if orientation=1;
> ; Z_LOWER, Z_UPPER: extent of array in Z direction with which to
> generate the mip.
> ; Only has an effect if orientation=2
> ;Default is to use complete array
>
> ; MODIFICATION HISTORY:
> ; 7/3/01 anne: orientation keyword and lower and upper bounds keywords
> added
> ; 7/10/02 anne: minimum keyword added
>
>
> ;-
>
> FUNCTION Mip, image,orientation=orientation , $
> maximum=maximum, minimum=minimum, $
> x_Lower=xLower,x_Upper=xUpper, $
> y_Lower=yLower,y_Upper=yUpper, $
> z_Lower=zLower,z_Upper=zUpper
>
> if n_elements(orientation) eq 0 then orientation = 2
> if keyword_set(minimum) then mode=1 else mode=0
>
> s=size(image)
>
> xsize = s[1]
> ysize = s[2]
> zsize = s[3]
>
> case orientation of
> 2: begin
> if keyword_set(zLower) then zLower=zLower>0 else zLower=0
> if keyword_set(zUpper) then zUpper=zUpper<zsize-1 else
> zUpper=zsize-1
> mipImage=image[*,*,zLower]
> if mode eq 0 then begin ; max intensity
> for i = zLower+1, zUpper do begin
> mipImage=mipImage>image[*,*,i]
> endfor
> endif else begin ; min_intensity
> for i = zLower+1, zUpper do begin
> mipImage=mipImage<image[*,*,i]
> endfor
> endelse
> end
> 1: begin
> if keyword_set(yLower) then yLower=yLower>0 else yLower=0
> if keyword_set(yUpper) then yUpper=yUpper<ysize -1 else
> yUpper=ysize-1
> mipImage=image[*,yLower,*]
> if mode eq 0 then begin ; max intensity
> for i = yLower+1, yUpper do begin
> mipImage=mipImage>image[*,i,*]
> endfor
> endif else begin ; min_intensity
> for i = zLower+1, zUpper do begin
> mipImage=mipImage<image[*,i,*]
> endfor
> endelse
> mipImage=reform(mipImage)
> end
>
> 0: begin
> if keyword_set(xLower) then xLower=xLower>0 else xLower=0
> if keyword_set(xUpper) then xUpper=xUpper<xsize-1 else
> xUpper=xsize-1
> mipImage=image[xLower,*,*]
> if mode eq 0 then begin ; max intensity
> for i = xLower+1, xUpper do begin
> mipImage=mipImage>image[i,*,*]
> endfor
> endif else begin ; min_intensity
> for i = zLower+1, zUpper do begin
> mipImage=mipImage<image[i,*,*]
> endfor
> endelse
> mipImage=transpose(reform(mipImage))
> ;using transpose maintains orientation so that y remains along
> vertical axis
> end
>
> else:
>
> endcase
>
>
> RETURN, mipImage
>
> END
>
>
>
>
> On Apr 12, 8:34 am, "StevenM" <s.maclel...@strath.ac.uk> wrote:
>> Hi all,
>>
>> I have a 3d data set as a 320x80x80 array. Can anyone tell me if
>> there is an easy way to do a maximum intensity projection using IDL.
>>
>> thanks
>>
>> Steven
>
>
>
>
>
|
|
|
Re: Maximum intensity projection (MIP) [message #53458 is a reply to message #53456] |
Thu, 12 April 2007 06:10  |
Anne Martel
Messages: 10 Registered: May 1995
|
Junior Member |
|
|
Steve,
For a mip in the x-y plane you just need to do
mipIm=data[*,*,0]
for i = 1,79 do mipIm = mipIm > data[*,*,i]
I've pasted my mip routine below - it gives you more control over the
orientation and slices to use. I posted an interactive GUI version on
the IDL website a few years ago - I think it was called xmip and it
should still be there,
Anne
$Id: mip.pro $
;
;+
; NAME:
; MIP
;
; PURPOSE:
; Function to return the max (or min) intensity projection of
; an array of images.
; CATEGORY:
;
;
; CALLING SEQUENCE:
; myMipImage=MIP(image)
;
; INPUTS:
; image - raw image image - must be a 3D array
; KEYWORD PARAMETERS:
; ORIENTATION: This gives the orientation of the mip image.
; default = 2 -ie mip generated using images (*,*,i)
;
can also have 0 or 1
; MAXIMUM: Generates max intensity projection image (the default)
; MINIMUM: Generates min intensity projection image
; X_LOWER, X_UPPER: extent of array in X direction with which to
generate the mip.
; Only has an effect if orientation=0
; Y_LOWER, Y_UPPER: extent of array in Y direction with which to
generate the mip.
; Only has an effect if orientation=1;
; Z_LOWER, Z_UPPER: extent of array in Z direction with which to
generate the mip.
; Only has an effect if orientation=2
;Default is to use complete array
; MODIFICATION HISTORY:
; 7/3/01 anne: orientation keyword and lower and upper bounds keywords
added
; 7/10/02 anne: minimum keyword added
;-
FUNCTION Mip, image,orientation=orientation , $
maximum=maximum, minimum=minimum, $
x_Lower=xLower,x_Upper=xUpper, $
y_Lower=yLower,y_Upper=yUpper, $
z_Lower=zLower,z_Upper=zUpper
if n_elements(orientation) eq 0 then orientation = 2
if keyword_set(minimum) then mode=1 else mode=0
s=size(image)
xsize = s[1]
ysize = s[2]
zsize = s[3]
case orientation of
2: begin
if keyword_set(zLower) then zLower=zLower>0 else zLower=0
if keyword_set(zUpper) then zUpper=zUpper<zsize-1 else
zUpper=zsize-1
mipImage=image[*,*,zLower]
if mode eq 0 then begin ; max intensity
for i = zLower+1, zUpper do begin
mipImage=mipImage>image[*,*,i]
endfor
endif else begin ; min_intensity
for i = zLower+1, zUpper do begin
mipImage=mipImage<image[*,*,i]
endfor
endelse
end
1: begin
if keyword_set(yLower) then yLower=yLower>0 else yLower=0
if keyword_set(yUpper) then yUpper=yUpper<ysize -1 else
yUpper=ysize-1
mipImage=image[*,yLower,*]
if mode eq 0 then begin ; max intensity
for i = yLower+1, yUpper do begin
mipImage=mipImage>image[*,i,*]
endfor
endif else begin ; min_intensity
for i = zLower+1, zUpper do begin
mipImage=mipImage<image[*,i,*]
endfor
endelse
mipImage=reform(mipImage)
end
0: begin
if keyword_set(xLower) then xLower=xLower>0 else xLower=0
if keyword_set(xUpper) then xUpper=xUpper<xsize-1 else
xUpper=xsize-1
mipImage=image[xLower,*,*]
if mode eq 0 then begin ; max intensity
for i = xLower+1, xUpper do begin
mipImage=mipImage>image[i,*,*]
endfor
endif else begin ; min_intensity
for i = zLower+1, zUpper do begin
mipImage=mipImage<image[i,*,*]
endfor
endelse
mipImage=transpose(reform(mipImage))
;using transpose maintains orientation so that y remains along
vertical axis
end
else:
endcase
RETURN, mipImage
END
On Apr 12, 8:34 am, "StevenM" <s.maclel...@strath.ac.uk> wrote:
> Hi all,
>
> I have a 3d data set as a 320x80x80 array. Can anyone tell me if
> there is an easy way to do a maximum intensity projection using IDL.
>
> thanks
>
> Steven
|
|
|
|