help-octave
[Top][All Lists]
Advanced

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

Re: grayscale image processing


From: Alasdair McAndrew
Subject: Re: grayscale image processing
Date: Thu, 2 Jan 2014 22:04:42 +1100

Here's another way of obtaining a N x 3 array.  With R and C as above:

[X,Y] = meshgrid(1:C,1:R);
reshape(cat(3,X,Y,im),R*C,3,1)

This way creates a multidimensional array containing X,Y and im, and then uses a single "reshape" to get the array you want.


On Thu, Jan 2, 2014 at 9:08 PM, Alasdair McAndrew <address@hidden> wrote:
To find the largest values, say in an 8-bit grayscale image, you can do

[i,j]=find(im==max(im(:)))

or for values which are nearly as large:

m = 10
[i,j]=find(im>=max(im(:))-m)

This will give you vectors of i and j indices.  And to look at pixel values around such a peak, you can always isolate a local neighbourhood with

k = 1
im(i(k)-2:i(k)+2,j(k)-2:j(k)+2)

which will give you a 5x5 neighbourhood centred on the first pixel in your list.

If you'd prefer a circular neighbourhood, try something like

rad = 3
[x,y] = meshgrid(-rad:rad);
circ = x.^2+y.^2>rad^2
im(i(k)-rad:i(k)+rad,j(k)-rad:j(k)+rad).*circ

Is this the sort of thing you want?

To get your 3 x N array, suppose your image has R rows and C columns.  That is:

[R,C] = size(im)

Then:

[X,Y] = meshgrid(1:R,1:C);
Z = X*Y
[reshape(X,Z,1),reshape(Y,Z,1),reshape(im,Z,1)]

There may be an easier way than this, but if there is I can't think of it right now.



On Mon, Dec 23, 2013 at 8:39 PM, fulviosaccoccia <address@hidden> wrote:
Dear Octave users,
this is my first post.
I would like to extract a 3xN matrix from grayscale image files (tiff, img,
cbf format). These images contain a series of "2D peaks". Each of these
peaks are ultimately a cluster of high intensity grayscale pixel I  already
know to follow a Normal distribution, over a background of low intensity
pixel. Then, I would like to obtain a three columns matrix where the first
two columns report the coordinates in pixels, while the third one report the
intensity of gray. Later, my purpose will be to analize the distribution of
the maximum of the intensity of gray. Ultimately, I would to reconstruct a
series of Gaussian by the data extracted from the images.
The final goal will be to ascertain if a "peak" in the original image
contain the contribution of a minor "satellite peak".
I have used

I=imread("file.tiff") in order to otain the I matrix but I do not know how
to deal with it to finally obtain the 3xN matrix.

Hoping I have been clear,
thank you to all
Fulvio



--
View this message in context: http://octave.1599824.n4.nabble.com/grayscale-image-processing-tp4660324.html
Sent from the Octave - General mailing list archive at Nabble.com.
_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave



--
Blog: http://amca01.wordpress.com
Web:  http://sites.google.com/site/amca01/
Facebook: http://www.facebook.com/alasdair.mcandrew



--
Blog: http://amca01.wordpress.com
Web:  http://sites.google.com/site/amca01/
Facebook: http://www.facebook.com/alasdair.mcandrew

reply via email to

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