現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
contrast gain of an image
4 ビュー (過去 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!
Silpa K
2019 年 10 月 23 日
Sir please tell me how can I do that.Iam new to image processing using MATLB.
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).
Silpa K
2019 年 11 月 3 日
Thank you Sir. If there any way to get a contrast gain that is less than one.
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!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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 (한국어)