comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Can i avoid the loop,help me speed up,thanks
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Can i avoid the loop,help me speed up,thanks [message #61883] Tue, 05 August 2008 04:48 Go to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On Aug 4, 9:35 pm, Chris <beaum...@ifa.hawaii.edu> wrote:
> On Aug 4, 11:31 am, Vince Hradil <hrad...@yahoo.com> wrote:
>
>
>
>> On Aug 4, 3:44 pm, "ben.bighair" <ben.bigh...@gmail.com> wrote:
>
>>> On Aug 4, 9:29 am, Rongchang Chen <chenrc1...@gmail.com> wrote:
>
>>>> I wrote a procedure to create sinograms from projections in
>>>> tomography,the main part of procedure please see below.
>>>> For large size and number projections,it's very very slow.
>>>> Can i avoid the loop(one is OK) to speed up,or another way to create
>>>> sinograms?
>>>> Thank you very much!!
>
>>>> ************
>>>> n_sinogra:number of sinogram
>>>> n_projection:number of projection
>>>> files_projection:a string vector contain Directory and name of
>>>> projection
>>>> files_sino:a string vector contain Directory and name of sinogram
>
>>>> for jj = 0,n_sinogram-1 do begin
>>>>     print,'now creating',jj+1,'th sinogram'
>>>>     sino = fltarr(sizepro[0],n_projection)
>
>>>>     for ii=0, n_projection-1 do begin
>>>>         image = float(read_image(files_projection[ii]))
>>>>         some processing of image
>>>>         sino(*,ii) = image(*,jj)
>>>>     endfor
>
>>>>     write_tiff,files_sino(jj),sino,/short,/float
>>>> endfor
>>>> *****************
>
>>> Hi,
>
>>> I don't think it is possible for anyone to penetrate where you are
>>> having trouble with the given information.  I think you might try
>>> using the builtin PROFILER routine for a start.  It should reveal to
>>> you where you are spending most of your time.
>
>>> Unrelated to the speed issue, you seem to be specifying TIFF output
>>> simultaneously as a SHORT integer and a FLOAT.  What type of image do
>>> you want to be saving?
>
>>> Cheers,
>>> Ben
>
>> I agree with Ben - the question is: what is in the "some processing of
>> image" step?  If this can be "vectorized", then you might be able to
>> avoid some looping.
>
> I would also add that you are taking a huge penalty by opening every
> file in each outer loop iteration. IO is very, very slow. If you are
> looking for a speedup, see if you can reverse the order of the loops
> and read each file only once. The next step is to see if you can
> eliminate your (currently) outer loop through vectorization, but this
> requires a more detailed description of what kind of image processing
> you are doing.
>
> Chris

I think Chris has hit the nail on the head... without knowing the
processing, I don't know exactly what the final answer will look like,
but I expect it to be something like:

sino = fltarr(sizepro[0],n_projection)
for ii=0l,n_projections-1 do begin
image = float(read_image(files_projection[ii]))
some_processing_that_updates_sino
endfor
for jj=0l,n_sinogram-1 do write_tiff,files_sino(jj),sino,/short,/float

Hopefully "some_processing_that_updates_sino" can be vectorized, but
even if it has to be a loop you should save lots of time.

-Jeremy.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Counting the lengths of continuous numbers in an array
Next Topic: Short array memory allocation

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:22:03 PDT 2025

Total time taken to generate the page: 0.00445 seconds