Plotting Blue Pixel Values against Distance
1 view (last 30 days)
Show older comments
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 Comments
Image Analyst
on 15 Mar 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
on 16 Mar 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.
Accepted Answer
Image Analyst
on 15 Mar 2022
Edited: Image Analyst
on 15 Mar 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?
0 Comments
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!