compare two arrays of different size

5 visualizaciones (últimos 30 días)
arman Yaraee
arman Yaraee el 6 de Nov. de 2011
Hi guys.
%%In this part we just find the coordinates of the required color
clear;
im = imread('Lighthouse.jpg');
n = 5;
figure, imshow(im)
[x,y] = ginput(n);
x = floor(x);
y = floor(y);
colour = zeros(n,3);
for i=1:size(x)
colour(i,:) = im(y(i),x(i),:);
end
%%Creating Color arrays to compare to the real picture.
% The mean
R = mean(colour(:,1));
G = mean(colour(:,2));
B = mean(colour(:,3));
% The standard deviation
r = std(colour(:,1));
g = std(colour(:,2));
b = std(colour(:,3));
% Find the coordinates of the match
% match of red
[i1 j1] = find(abs(im(:,:,1)- R) <= r);
% match of green
[i2 j2] = find(abs(im(:,:,2)- G) <= g);
% match of blue
[i3 j3] = find(abs(im(:,:,3)- B) <= b);
Actually I need to combine these six variables into two. I want to match the points in i1,j1 == i2,j2 == i3,j3. My big problem is that they have different dimensions. other than looping through them which takes ages what is the best way to do it?

Respuestas (1)

Image Analyst
Image Analyst el 6 de Nov. de 2011
And what do you want to do with i1, j1, i2, etc. once you have them? I think you'd better take a look at my color segmentation tutorials in my File Exchange. Color image analysis is kind of my specialty as you can see from my logo. The RGB space one is similar to what you're doing. Basically you do it by thresholding, like you're doing, except that I end up with images with only the color that you're interested in instead of a long list of coordinates. The HSV and Delta E color segmentation methods are also well worth checking out and understanding. http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by