how to declare a specified row in an image as a variable?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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);
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 4 Mär. 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));
0 Kommentare
Weitere Antworten (1)
Guillaume
am 4 Mär. 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');
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!