Borrar filtros
Borrar filtros

Plotting Blue Pixel Values against Distance

1 visualización (últimos 30 días)
Hollis Williams
Hollis Williams el 15 de Mzo. de 2022
Comentada: Jan el 16 de Mzo. de 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 comentarios
Image Analyst
Image Analyst el 15 de Mzo. de 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 el 16 de Mzo. de 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.

Iniciar sesión para comentar.

Respuesta aceptada

Image Analyst
Image Analyst el 15 de Mzo. de 2022
Editada: Image Analyst el 15 de Mzo. de 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?

Más respuestas (0)

Categorías

Más información sobre Images en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by