Re: Can i avoid the loop,help me speed up,thanks [message #61885 is a reply to message #61883] |
Mon, 04 August 2008 18:35   |
Chris[6]
Messages: 84 Registered: July 2008
|
Member |
|
|
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
|
|
|