Plotting Blue Pixel Values against Distance

1 Ansicht (letzte 30 Tage)
Hollis Williams
Hollis Williams am 15 Mär. 2022
Kommentiert: Jan am 16 Mär. 2022
I have obtained the following blue strip where the ''brightness'' decreases as one moves from left to right.
If the total distance across the strip is normalized to be 1, is there a way in image processing with MATLAB to plot the pixel value as one goes from the far left to the far right, I am trying to show that the pixel value increases linearly with the distance.
  6 Kommentare
Image Analyst
Image Analyst am 15 Mär. 2022
If you need my code below to work on a different colorspace, then just convert it with the appropriate function. But just let me know if it worked in RGB color space first.
Jan
Jan am 16 Mär. 2022
Using the euclidean distance to a "certain" point on the left side is useful, if the underlying physikal efffect has a circulare geometry. The distribution along the left side doe not look like this is the case. Image Analyst posted a code using the hroizontal distance and the results look promissing.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Image Analyst
Image Analyst am 15 Mär. 2022
Bearbeitet: Image Analyst am 15 Mär. 2022
Try this:
rgbImage = imread('blue ramp.png');
% Separate the image into red, green, and blue parts.
[r,g,b] = imsplit(rgbImage);
% Get average horizontal profile of the color channel.
horizontalProfileR = mean(r, 1);
horizontalProfileG = mean(g, 1);
horizontalProfileB = mean(b, 1);
x = [1 : size(r, 2)]; % x going from 1 to number of columns in the image.
% Rescale from 0 to 1
x = rescale(x, 0, 1);
plot(x, horizontalProfileR, 'r-', 'LineWidth', 3);
hold on;
grid on;
plot(x, horizontalProfileG, 'g-', 'LineWidth', 3);
plot(x, horizontalProfileB, 'b-', 'LineWidth', 3);
title('Horizontal Profile', 'FontSize', 20);
xlabel('Percentage of the way across', 'FontSize', 20);
ylabel('Gray Level', 'FontSize', 20);
legend('R', 'G', 'B', 'Location', 'southwest');
Does that meet your needs?

Weitere Antworten (0)

Kategorien

Mehr zu Image Processing and Computer Vision finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by