how to get the same contrast in an image?
조회 수: 2 (최근 30일)
이전 댓글 표시
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
Abhishek Kolla
2021년 11월 12일
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
2021년 11월 12일
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.
답변 (2개)
yanqi liu
2021년 11월 1일
sir,may be use the hist vector, such as
J = histeq(I,hgram)
댓글 수: 1
Abhishek Kolla
2021년 11월 1일
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
2021년 11월 12일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Processing and Computer Vision에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!