Plotting Blue Pixel Values against Distance

1 回表示 (過去 30 日間)
Hollis Williams
Hollis Williams 2022 年 3 月 15 日
コメント済み: Jan 2022 年 3 月 16 日
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 件のコメント
Image Analyst
Image Analyst 2022 年 3 月 15 日
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 2022 年 3 月 16 日
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.

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2022 年 3 月 15 日
編集済み: Image Analyst 2022 年 3 月 15 日
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 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by