how to declare a specified row in an image as a variable?

5 vues (au cours des 30 derniers jours)
Sean
Sean le 4 Mar 2015
Commenté : Sean le 4 Mar 2015
I have a folder of images and I know which 2 rows I want to plot out and define on all of my images (rows 200 and 315). To begin with I used the following code to plot the 2 rows on one of the images:
A=imread('K1.BMP');
AR=A(:,:,1); %remove rgb, Grey scale images
%plot a green line for row 200 the whole way across the image (Image is 1024x886)
%plot a blue line for row 315 the whole way across the image
plot([0 1024],[200 200], 'g');
plot([0 1024], [315 315], 'b');
How do I declare these lines as variables so I can then plot the same line on the rest of my images? The reason I'm doing this is because I want to process all the pixels in the specified rows of the image, i.e. call row 1 'X1' and row 2 'X2' and then find its mean and standard deviation using:
meanX1 = mean(X1);
stdX1 = std(X1);
meanX2 = mean(X2);
stdX2 = std(X2);

Réponse acceptée

Image Analyst
Image Analyst le 4 Mar 2015
You mean like this:
[rows, columns] = size(AR);
y1 = 200
y2 = 315
row1 = AR(y1, :); % Extract this line of gray levels from the image.
row2 = AR(y2, :);
plot([0, columns], [y1, y1], 'g');
plot([0, columns], [y2, y2], 'b');
meanX1 = mean(row1);
stdX1 = std(double(row1));
meanX2 = mean(row2);
stdX2 = std(double(row2));

Plus de réponses (1)

Guillaume
Guillaume le 4 Mar 2015
Shouldn't your x coordinates start at 1 or 0.5
Anyway:
img = imread('cameraman.tif');
rowtoplot = 200;
imshow(img)
hold on
plot([0.5 size(img, 2)+0.5], [rowtoplot rowtoplot], 'g');

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by