フィルターのクリア

how to calculate Contrast Improvment Ratio - CIR

11 ビュー (過去 30 日間)
Itzhak Mamistvalov
Itzhak Mamistvalov 2021 年 7 月 11 日
コメント済み: Itzhak Mamistvalov 2021 年 7 月 11 日
Hey everyone,
Im trying to calculate to Contrast Improvment Ratio (CIR) between enhanced and unenhanced images within region of interest R. This is the formula Im using:
where C(x, y) and C¯(x,y)C¯(x,y) are the local contrast values at (x, y) of the unenhanced and enhanced images, respectively.
The Local contrast value C(x, y) computed as
where p and a are the mean values within the center region (3 × 3) pixels and the neighborhood, or surrounding region, (7 × 7) pixels, respectively.
I have a problem to actually write this into a matlab code.
I would appreciate your help, thanks!
  2 件のコメント
Simon Chan
Simon Chan 2021 年 7 月 11 日
Does the surrounding region includes or excludes the center region?
Itzhak Mamistvalov
Itzhak Mamistvalov 2021 年 7 月 11 日
Actually, Im not sure about it. I guess it is, I wrote here the defenition and the explanation of the formula (this is an academic task).

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2021 年 7 月 11 日
Try this:
windowSize7 = 7;
windowSize3 = 3;
kernel3 = ones(windowSize3) / windowSize3^2;
% Counting center 3x3 region
kernel7 = ones(windowSize7) / windowSize7^2;
% If you don't want to count the center 3x3 region, Make the kernel this way.
kernel7Ring = ones(windowSize7) / windowSize7^2;
kernel7Ring(3:5, 3:5) = 0;
% Here you choose. If you want the center expluded, add in the line below.
% kernel7 = kernel7Ring;
% Compute C1
p3 = conv2(double(grayImage1), kernel3, 'same');
countImage = conv2(ones(size(grayImage1)), kernel7, 'same');
glSumImage = conv2(double(grayImage1), kernel7, 'same');
p7 = conv2(double(grayImage1), kernel7, 'same');
C1 = imabsdiff(p3,p7) / (p3 + p7);
subplot(2, 2, 3);
imshow(C1, []);
impixelinfo;
title('C1', 'FontSize', fontSize);
% Compute Cbar
p3 = conv2(double(grayImage2), kernel3, 'same');
countImage = conv2(ones(size(grayImage2)), kernel7, 'same');
glSumImage = conv2(double(grayImage2), kernel7, 'same');
p7 = glSumImage ./ countImage;
Cbar = imabsdiff(p3,p7) / (p3 + p7);
subplot(2, 2, 4);
imshow(Cbar, []);
impixelinfo;
title('C2', 'FontSize', fontSize);
numerator = (C1 - Cbar).^2;
denominator = C1 .^ 2;;
CIR = sum(numerator(:)) / sum(denominator(:))
  5 件のコメント
Image Analyst
Image Analyst 2021 年 7 月 11 日
If you're going to exclude the central 3x3 region, then there are not 7x7=49 pixels to be averaged over, you need to average over 49 - 9 = 40 because you're not going to consider the central 3x3 = 9 pixels. So while a convolution gets you the average over the whole 49 pixels if you do
kernel7 = ones(windowSize7) / windowSize7^2;
if you use a kernel that is basically a ring shape, you need to get the average by summing the 40 gray levels and then dividing by 40. So to add up the gray levels of the 40, I apply that ring-shaped kernel to the image. That gets me the sum of the 40 pixels around that point. Now to find out how many pixels are in there (40 except near the edges) I apply the ring-shaped kernel to an image of all 1's. That will count the pixels we are considering at each point. Then we divide them to get the average of the (mostly) 40 pixels.
Itzhak Mamistvalov
Itzhak Mamistvalov 2021 年 7 月 11 日
Thanks again!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with Image Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by