이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
contrast gain of an image
조회 수: 2 (최근 30일)
이전 댓글 표시
Silpa K
2019년 10월 22일
I have an image that from an hazy image model,a haze free image.I need to find the contrast gain of this image.How can I find that,please help me.
답변 (1개)
Image Analyst
2019년 10월 22일
Perhaps look at the ratio of the ranges, or the standard deviations, unless you have a specific formula someone recommends.
댓글 수: 15
Silpa K
2019년 10월 22일
There is no recommended specific formula for this. Is there any function available for this.
Is it possible to find contrast gain using ratio of the ranges, or the standard deviations.
Image Analyst
2019년 10월 22일
Yes, that's what I suggested, and are some metrics. If they work for you, then great!
Image Analyst
2019년 10월 23일
Try
contrastGain = std(image2(:)) / std(image1(:))
rangeGain = range(image2(:)) / range(image1(:))
Silpa K
2019년 10월 29일
Sir, I tried this one,I am not getting efficient result.Is there is any other methods for finding contrast gain.
Image Analyst
2019년 10월 29일
How are you defining efficiency? By the length of time it takes???
It should not take that long to compute. How long is it taking for you?
Silpa K
2019년 10월 30일
편집: Image Analyst
2019년 10월 30일
clc
clear
rng default
% Image and parameters
M= imread('img1.tiff');
I=im2double(M);
tot = sum(double(I(:)));
[K L] = size(I);
A=((1./(K*L))*tot);
SD=std2(I);
t1= (I./A);
t2= SD * t1;
t= 1-t2;
Hazy = @(I,A,t) (I-A*(1-t))./t; % Define your function, make sure it is element-wise
J1 = Hazy(I,A,t);
figure,
subplot(1,2,1)
imshow(I,[])
subplot(1,2,2)
imshow(J1,[])
contrastGain = std(J1(:)) / std(I(:));
I am using the above code. I need to find contrast gain of the output image.
Image Analyst
2019년 10월 30일
How are you defining efficiency? By the length of time it takes???
It should not take that long to compute. How long is it taking for you?
Silpa K
2019년 11월 1일
Sir,we are expecting a value that is less than one. For computing it not taking more amount of time only less than 4 or 5 minutes.
Image Analyst
2019년 11월 1일
Try this:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures if you have the Image Processing Toolbox.
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 14;
rng default
% Image and parameters
% grayImage = imread('cameraman.tif');
grayImage = imread('pout.tif');
[rows, columns, numberOfColorChannels] = size(grayImage)
startTime = tic;
if numberOfColorChannels > 1
% It's not gray scale, it's color, so convert to gray scale.
grayImage = rgb2gray(grayImage);
end
doubleImage = im2double(grayImage);
tot = sum(double(doubleImage(:)));
% Compute some factors.
A = ((1 ./ (rows*columns)) * tot);
stdDevOriginal = std2(doubleImage);
t1 = doubleImage ./ A;
t2 = stdDevOriginal * t1;
t = 1 - t2;
fprintf('Starting de-hazing process...\n');
% Define your function, make sure it is element-wise
Hazy = @(I, A, t) (I - A * (1 - t)) ./ t;
% Apply the function to the double image.
J1 = Hazy(doubleImage, A, t);
stdDevProcessed = std(J1(:));
contrastGain = stdDevProcessed / stdDevOriginal;
elapsedTime = toc(startTime);
fprintf('Done with de-hazing process.\nIt took %.2f seconds.', elapsedTime);
subplot(2, 2, 1)
imshow(doubleImage)
caption = sprintf('Original image. StdDev = %.3f', stdDevOriginal);
title(caption, 'FontSize', fontSize);
axis('on', 'image');
impixelinfo;
subplot(2, 2, 2)
imshow(J1)
caption = sprintf('Processed Image. StDev = %.3f\n with contrast gain %.2f', ...
stdDevProcessed, contrastGain);
title(caption, 'FontSize', fontSize);
axis('on', 'image');
impixelinfo;
subplot(2, 2, 3)
imshow(t)
title('The "t" image', 'FontSize', fontSize);
axis('on', 'image');
impixelinfo;
%------------------------------------------------------------------------------
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
% Get rid of tool bar and pulldown menus that are along top of figure.
% set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
message = sprintf('Done!\nThe elapsed time was %.3f seconds.', elapsedTime);
fprintf('%s\n', message);
uiwait(helpdlg(message));
![0001 Screenshot.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/246067/0001%20Screenshot.png)
How gigantic is your image? For my demo image, I see
rows =
291
columns =
240
numberOfColorChannels =
1
Starting de-hazing process...
Done with de-hazing process.
It took 0.01 seconds.Done!
The elapsed time was 0.011 seconds.
Note that it took only a hundredth of a second, not 5 minutes. Also note that the haze removal is not that good. You might want to investigate your algorithm further (I did not do that - I just took the formula you gave).
Image Analyst
2019년 11월 3일
Yes, if the image became less contrasty, like if the processed image was a completely uniform gray level.
Silpa K
2019년 11월 4일
How can I do that? What is the method to get a image completely uniform gray level.
Image Analyst
2019년 11월 4일
Like this:
grayImage = 128 * ones(480, 640, 'uint8');
That makes an image with 480 rows and 640 columns with a uniform gray level of 128.
Silpa K
2019년 11월 5일
How can I apply it into the output image.I need a output image that is fully uniform gray level,bcz I need a output image with less contrast.
참고 항목
태그
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)