how to get the same contrast in an image?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi! I have image o.png which shows a difference in the contrast of the pixels, there is like a "line" that divide two different parts. I tried with histeq but I don't get any results. Any suggestions? Thank you
9 comentarios
Abhishek Kolla
el 12 de Nov. de 2021
The step by step process to save and export the final modified image can be found here Get Started with Image Viewer App - MATLAB & Simulink (mathworks.com)
Image Analyst
el 12 de Nov. de 2021
Taking the histogram or increasing contrast with histogram equalization or imadjust() will not help you with finding the line. Just think about it.
I'd try thresholding and then do some cleanup with bwareafilt() and sgolayfilt(). I'll give code later today if I have time.
Respuestas (2)
yanqi liu
el 1 de Nov. de 2021
sir,may be use the hist vector, such as
J = histeq(I,hgram)
1 comentario
Abhishek Kolla
el 1 de Nov. de 2021
In the above function hgram refers to target histogram. We can use it when the histogram of output image has to approximately match target histogram hgram
Image Analyst
el 12 de Nov. de 2021
To find the left edge of that bright strip, try this:
% Demo by Image Analyst
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
markerSize = 40;
%--------------------------------------------------------------------------------------------------------
% READ IN IMAGE
fileName = 'o.PNG';
grayImage = imread(fileName);
% Get the dimensions of the image.
% numberOfColorChannels should be = 1 for a gray scale image, and 3 for an RGB color image.
[rows, columns, numberOfColorChannels] = size(grayImage)
if numberOfColorChannels > 1
% It's not really gray scale like we expected - it's color.
% Extract the blue channel (so the magenta lines will be white).
grayImage = grayImage(:, :, 3);
end
%--------------------------------------------------------------------------------------------------------
% Display the image.
subplot(2, 2, 1);
imshow(grayImage, []);
impixelinfo;
axis('on', 'image');
title('Original Gray Scale Image', 'FontSize', fontSize, 'Interpreter', 'None');
hold on
drawnow;
% Maximize window.
g = gcf;
g.WindowState = 'maximized'
drawnow;
% Get rid of white frame.
frame = grayImage == 240;
grayImage(frame) = 0;
subplot(2, 2, 2);
imhist(grayImage);
grid on;
low = 104;
high = 255;
% [low, high] = threshold(low, high, grayImage)
mask = grayImage > low;
% Take biggest blob
mask = bwareafilt(mask, 1);
% Fill holes.
mask = imfill(mask, 'holes')
% Display the image.
subplot(2, 2, 3);
imshow(mask, []);
impixelinfo;
axis('on', 'image');
title('Mask Image', 'FontSize', fontSize, 'Interpreter', 'None');
hold on
drawnow;
% Scan down getting left edge of bright strip.
leftEdges = nan(rows, 1);
hold on;
for row = 1 : rows
t = find(mask(row, :), 1, 'first');
if ~isempty(t)
leftEdges(row) = t;
plot(t, row, 'r.', 'MarkerSize', 8);
end
end
subplot(2, 2, 4);
plot(leftEdges, 'b-', 'LineWidth', 2);
grid on;
title('Left Edges', 'FontSize', fontSize, 'Interpreter', 'None');
xlabel('Row', 'FontSize', fontSize, 'Interpreter', 'None');
ylabel('Column of left edge', 'FontSize', fontSize, 'Interpreter', 'None');
hold on
drawnow;
0 comentarios
Ver también
Categorías
Más información sobre Image Processing and Computer Vision en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!