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

Could you please share the picture file?
Jan
Jan 2022년 3월 15일
편집: Jan 2022년 3월 15일
@Davide Masiello: Simply right click on the image and download it.
@Hollis Williams: What do you call "the pixels value"? The pixels are defined as RGB vectors. Which "distance" do you mean? The area has 2 dimensions, so is it the horizontal distance or the euklidean distance from a certain point?
There is some noice in the image. Do you want to remove it at first?
What about converting the colors from RGB to HSV, such that the "brightness" is a scalar for each pixel?
Hollis Williams
Hollis Williams 2022년 3월 15일
편집: Hollis Williams 2022년 3월 15일
I tried going along manually in image processing mode and obtained a bunch of RGB vectors. I am then able to convert these to values for ''hue'', ''saturation'' and ''value''. Which one of these corresponds to what would be called the ''brightness scalar'' of a pixel?
Edit: Ah I see, it's the value which corresponds to ''brightness'. Only problem is that the brightness does not seem to vary much from one end to the other. I may need to re-do the image.
I just meant the Euclidean distance as one starts on the far left at a certain height, set this to zero, and then moves to the right.
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일

0 개 추천

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개)

질문:

2022년 3월 15일

댓글:

Jan
2022년 3월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by