help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Avoiding looping when applying a 'find' function to an array - David


From: Stefan van der Walt
Subject: Re: Avoiding looping when applying a 'find' function to an array - David Bateman reply
Date: Wed, 13 Apr 2005 18:17:59 +0200
User-agent: Mutt/1.5.6+20040907i

Can't you convert your image to its indexed version, and then use
ind2rgb to convert it from whichever colourmap you want?

 -- Function File: [R, G, B] = ind2rgb (X, MAP)
     Convert an indexed image to red, green, and blue color components.
     If MAP is omitted, the current colormap is used for the conversion.

Regards
Stefan

On Wed, Apr 13, 2005 at 06:03:41PM +0200, Harbinson, Jeremy wrote:
>  Hi,
> Thanks for the speedy response.
> There is an extra problem which I left out in the earlier posting in
> order to try and keep it simpler, but which may be relevant to the
> look_up_table function. This seems to expect a two-column table. What I
> am writing at the moment is really a prototype for something where I
> will have to find a value in four column look-up table - three columns
> of indices and one column of return values. 
> 
> Ultimately I need to convert a false colour image back to the original
> data array.  The false colour image is a 24 bit tiff file which I can
> convert to three arrays corresponding to the R, G and B channels using
> ImageJ. I have been able to create a table of R, G and B values matched
> with the corresponding original data values - a four column table. In
> the end I need to locate a row (and thus an output value) in the look-up
> table based on a comparison of elements from three input arrays (and
> many rows in the look-up table will have many entries in the 'red'
> column = 255, or entries in the green column = 0, for example):
> 
> I was planning to use a find function such as the following (which seems
> to work):
> 
> Location_of_output_value= find(red_channel_array(I,J) ==
> look_up_table(:,1) & green_channel_array(I,J) == look_up_table(:,2) &
> blue_channel_array(I,J) == look_up_table(:,3)) 
> 
> Where the red values in the look-table are found in (:,1), green in
> (:,2) and blue in (:,3).  
> 
> Sorry that my first posting was misleading,
> 
> All the best,
> Jeremy
> 
> 
> -----Original Message-----
> From: David Bateman [mailto:address@hidden 
> Sent: woensdag 13 april 2005 17:20
> To: Harbinson, Jeremy
> Cc: address@hidden
> Subject: Re: Avoiding looping when applying a 'find' function to an
> array
> 
> Jeremy
> 
> Have you seen the "lookup" function in octave-forge? I believe it does
> exactly what you want. Follow your syntax below, it would be used
> something like
> 
> output_array = look_up_table (lookup (look_up_table, input_array));
> 
> Regards
> David
> 
> Harbinson, Jeremy wrote:
> 
> >Hi,
> >I have a problem which can be easily solved by looping, but which I 
> >would like to try to solve by avoiding loops.
> > 
> >I need to transform one array to another equally sized array using a 
> >look-up table.
> >
> >If the input array is A, then I take the value of each element of array
> 
> >A one by one, and using the 'find' function, I find the appropriate 
> >value for the matching element for the output array via the look-up 
> >table. Looping over every element in array A works just fine - for each
> 
> >element in A I can obtain an output value for the output array. However
> 
> >I can not think of way of doing this same task without looping - that 
> >is, applying the 'find' function to each element and producing an 
> >output array without looping.
> >
> >If I input:
> >
> >Location_of_value_for_output_array = find(input_array(1,1) ==
> >look_up_table)
> >
> >then I get the correct location in the look-up table for the value 
> >required in the output array, and then I increment the index of 
> >input_array etc - this is slow because the array is 512 times 512 array
> 
> >(a graphics file) and the look-up table is 574 rows long.
> >
> >However if I try the following:
> >
> >Location_of_value_for_output_array = find(input_array(:,:) ==
> >look_up_table)
> >
> >Or
> >
> >Location_of_value_for_output_array = find(input_array == look_up_table)
> >
> >then I have no success.
> >Any help would be much appreciated,
> >Thanks,
> >Jeremy Harbinson      
> >
> >
> >
> >-------------------------------------------------------------
> >Octave is freely available under the terms of the GNU GPL.
> >
> >Octave's home on the web:  http://www.octave.org How to fund new 
> >projects:  http://www.octave.org/funding.html
> >Subscription information:  http://www.octave.org/archive.html
> >-------------------------------------------------------------
> >
> >  
> >
> 
> 



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]