matrix of image, imagine processing toolbox

I am beginner in image processing toolbox, i have to use this image
how i create matrix of image, when I need only the points that are black so I could continue to work with the coordinates.
THANKS

1 Kommentar

Tomas
Tomas am 16 Nov. 2013
Bearbeitet: Walter Roberson am 17 Nov. 2013
I = imread('image.png');
imshow(I)
[m n]=size(I)
I = double(I);
i dont know how to get matrix from binary image,

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Image Analyst
Image Analyst am 17 Nov. 2013

0 Stimmen

If the badly-named I matrix is already a binary image as you said, then you already have the coordinates as the binary image. In the event that I is really a gray scale image and not a binary image, you can turn it into a binary image (class will be "logical") by thresholding:
binaryImage = I < 127; % or whatever value is between black and white.
In the unlikely event that the binary image is not suitable and you really need vectors of rows and columns, you can do this to binaryImage:
[rows, columns] = find(binaryImage);
So rows(k) and columns(k) refer to the same pixel if k is the same. If you want in a single matrix, of (x,y) form, then you can do
xy = [columns, rows];

13 Kommentare

Tomas
Tomas am 17 Nov. 2013
i need basically a simple binary imagine,shows clustering. clustering will only be black places in image, white be background. I want to create matrix from binary image, i dont know how to get matrix coordinates only black colors
Image Analyst
Image Analyst am 17 Nov. 2013
My first line of code above showed you how to do that. The image is most likely what you need. If you do need the row and column arrays, then my second line of code shows you how to do that. I guess I'm confused why you're asking again because I'm just giving you the same answer and don't know why you don't understand it.
Tomas
Tomas am 17 Nov. 2013
I dont understand the image, so my questions are incomprehensible and my english is quite poor, Thank you for your answers and time
Image Analyst
Image Analyst am 17 Nov. 2013
Bearbeitet: Image Analyst am 17 Nov. 2013
Why don't you tell us what your final objective is, rather than the next step in some unspecified multi-step algorithm? The coordinates is not the final step of whatever you want to do - it's only the next step. What do you want to do after that? Then I can see whether the image is fine, or if you really need the coordinates.
Tomas
Tomas am 17 Nov. 2013
Bearbeitet: Tomas am 17 Nov. 2013
i have to clustering image, for example this picture
I have to clustering black points on picture I have to use hierarchical clustering(Agglomerative- i have a program ) My output will be the black point in the clusters, by using the clustering methods.
I dont know, how to get matrix to work out a picture
Image Analyst
Image Analyst am 17 Nov. 2013
Is that one cluster, or 14 or 15 clusters?
Tomas
Tomas am 17 Nov. 2013
at the beginning you can choose how much I want clusters
So use the code I gave you
[rows, columns] = find(binaryImage);
and plug rows and columns into kmeans or something.
Tomas
Tomas am 17 Nov. 2013
ok, thanks
Image Analyst
Image Analyst am 17 Nov. 2013
You're welcome. If we're done, close out the question by marking as Accepted. Thanks.
Tomas
Tomas am 17 Nov. 2013
Bearbeitet: Walter Roberson am 17 Nov. 2013
one more question, how i use [rows, columns] = find(binaryImage); I dont know, how i have to use.
my code is so far
I = imread('image.png');
imshow(I);
[m n]=size(I)
I = double(I);
binaryImage = I < 127
[rows,columns]=find(binaryImage)
[idx,ctrs] = kmeans(X,2,.......)
how create to matrix X with rows and columns ?, maybe stupid question, i dont know :)
Thanks
Walter Roberson
Walter Roberson am 17 Nov. 2013
Bearbeitet: Image Analyst am 17 Nov. 2013
X = [rows(:), columns(:)];
Tomas
Tomas am 17 Nov. 2013
ok thanks

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by