Image Sharpness Calculation ?

I have an issue with Image sharpness calculation, iam trying to code the formula below , but iam getting error :
The formula is :
where
.
and
: represents the horizontal/vertical gradient at pixel (x,y) obtained via the Sobel filter.
then S is :
.
and there is an issue with image gradient, if the image has no same hieght width the equation will not work ??
I have the code below for L(x,y) :
clear all;
my_image = im2double(imread('lena512.tif'));
my_image1 = my_image(:,:,1);
A=my_image1;
% use the help of a bigger matrix
B=nan(size(A)+2);
B(2:end-1,2:end-1)=A;
% pre-define memory for result
sharpness = 0*A;
% calculate!
for i=2:size(A,1)+1,
for j=2:size(A,2)+1,
tmp(2,2)=nan;
sharpness(i,j)= (temp (i-1,j)) + (temp(i+1,y) -temp(i,j-1)-temp(i,y+1);
end
end

2 commentaires

KALYAN ACHARJYA
KALYAN ACHARJYA le 11 Fév 2020
What is I^2(x)?
shawin
shawin le 11 Fév 2020
I updated the formula , sorry for that

Connectez-vous pour commenter.

Réponses (1)

KALYAN ACHARJYA
KALYAN ACHARJYA le 11 Fév 2020

1 vote

my_image1 = my_image(:,:,1);
sharpness=0;
[r,c]=size(my_image1);
for i=2:r-1
for j=2:j-1
L=(my_image1(i-1,j)+my_image1(i+1,j)-my_image1(i,j-1)-my_image1(i,j+1))^2;
sharpness(i,j)=L*(I^2(x)+I^2(y))
%..................^ ^ Change the I^2(x) and I^2(y)..I didnot undestand thease two I(x) and I(y)
end
end
sharpness

6 commentaires

shawin
shawin le 16 Fév 2020
Modifié(e) : shawin le 16 Fév 2020
Please why we are taking the image as :
my_image1 = my_image(:,:,1); Only the red chanel ??
KALYAN ACHARJYA
KALYAN ACHARJYA le 16 Fév 2020
You have mentioned in the posted code. May be red channel have maximum imformation in the test images. Considering the 1 plane reduce to complexity with respect to dela with 3 planes.
shawin
shawin le 16 Fév 2020
Can I convert the images to grayscale images then calculate the sharpness.
Just read the grayscale images ??
KALYAN ACHARJYA
KALYAN ACHARJYA le 16 Fév 2020
yes
shawin
shawin le 16 Fév 2020
Thank you :)
shawin
shawin le 21 Fév 2020
Modifié(e) : shawin le 27 Fév 2020
Thank you

Connectez-vous pour commenter.

Catégories

En savoir plus sur Images dans Centre d'aide et File Exchange

Question posée :

le 11 Fév 2020

Modifié(e) :

le 27 Fév 2020

Community Treasure Hunt

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

Start Hunting!

Translated by