correcting x-ray image

hello... i have the following code to correct the contrast of x-ray image,, but at last it gives a black image not x-ray,, Can any body help ???
load('heel_effect.mat')
imread('Hand.png')
subplot 231
imshow('Hand.png')
title('Origin')
tissue=tissue_eq_slab_image ;
h=x_ray_HeelEffect_image;
subplot 232
imagesc(tissue); colormap gray
title('Tissue Slab')
subplot 233
imagesc(h); colormap gray
title('Heel effect')
[M,N]=size(tissue);
mid_line=tissue(M/2,:);
subplot 234
imshow(mid_line)
title('Mid Line')
[m,n]=size(mid_line);
for c=1:n
T(c)=mid_line(:,c);
end
subplot 235
plot(1:n,T)
title('Relation')
log_T=log (double(T+eps));
log_c=log(double((1:n)+eps));
% I=A*x^Gama
%Ln I=Ln A+ Gama Ln x
z=polyfit (log_c, log_T,1);
Gama=z(1,1); %slope= Gama
A=exp(z(1,2)); %constant=Ln A
[m1,n1]=size(h);
for i=1:n1
corrected(:,n1)=tissue(:,n1)/A*(n1.^Gama);
end
subplot 236
imagesc(corrected)
title('Corrected Image')

11 件のコメント

sixwwwwww
sixwwwwww 2013 年 10 月 12 日
編集済み: sixwwwwww 2013 年 10 月 12 日
Can you please attach the image? Can you please format your code to be displayed correctly using "{} Code"?
Christine Ak
Christine Ak 2013 年 10 月 12 日
load('heel_effect.mat')
imread('Hand.png')
subplot 231
imshow('Hand.png')
title('Origin')
tissue=tissue_eq_slab_image ;
h=x_ray_HeelEffect_image;
subplot 232
imagesc(tissue); colormap gray
title('Tissue Slab')
subplot 233
imagesc(h); colormap gray
title('Heel effect')
[M,N]=size(tissue);
mid_line=tissue(M/2,:);
subplot 234
imshow(mid_line)
title('Mid Line')
[m,n]=size(mid_line);
for c=1:n
T(c)=mid_line(:,c);
end
subplot 235
plot(1:n,T)
title('Relation')
log_T=log (double(T+eps));
log_c=log(double((1:n)+eps));
% I=A*x^Gama
%Ln I=Ln A+ Gama Ln x
z=polyfit (log_c, log_T,1);
Gama=z(1,1); %slope= Gama
A=exp(z(1,2)); %constant=Ln A
[m1,n1]=size(h);
for i=1:n1
corrected(:,n1)=tissue(:,n1)/A*(n1.^Gama);
end
subplot 236
imagesc(corrected)
title('Corrected Image')
sixwwwwww
sixwwwwww 2013 年 10 月 12 日
Dear Christine, "heel_effect.mat" is not attached yet and also can you please explain what is meaning of these lines of your code?
tissue=tissue_eq_slab_image;
h=x_ray_HeelEffect_image;
because variables "tissue_eq_slab_image" and "x_ray_HeelEffect_image" are not defined anywhere. So I assume that you mean as follows
tissue_eq_slab_image = imread('Hand.png')
x_ray_HeelEffect_image = load('heel_effect.mat')
Is it correct?
Christine Ak
Christine Ak 2013 年 10 月 12 日
Thank U 4 replying
Those variables are in heel_effect.mat file which i can't attach it here !
the problem is not here
but i don't know what is the error exactly :(
sixwwwwww
sixwwwwww 2013 年 10 月 12 日
what is size of your ".mat" file?
Image Analyst
Image Analyst 2013 年 10 月 12 日
We can't really run your code unless you attach the mat file - you have to zip it up for now (until Answers gets that issue fixed). Have you actually observed values of corrected in the variable editor and verified that all values are exactly zero? Or does it just look black when you display it?
Christine Ak
Christine Ak 2013 年 10 月 12 日
編集済み: Christine Ak 2013 年 10 月 12 日
160 K I've submitted the File heel_effect.mat
Image Analyst
Image Analyst 2013 年 10 月 12 日
Nothing is attached.
Christine Ak
Christine Ak 2013 年 10 月 12 日
i can't attach it here !!
Image Analyst
Image Analyst 2013 年 10 月 12 日
zip up the mat file and click the paper clip icon when you make a comment!!
Wesam Mohamed
Wesam Mohamed 2020 年 6 月 9 日
Is this the full answer with run ?!

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

回答 (1 件)

Youssef  Khmou
Youssef Khmou 2013 年 10 月 12 日

0 投票

You can use the histogram equalization , see this example :
I = imread('tire.tif');
J = histeq(I);
imshow(I)
figure, imshow(J)
see
doc histeq

6 件のコメント

Christine Ak
Christine Ak 2013 年 10 月 12 日
Thxx 4 Replying but the image i have is 3 Dimensional...."" histeq"" function gives error :(
Youssef  Khmou
Youssef Khmou 2013 年 10 月 12 日
編集済み: Youssef Khmou 2013 年 10 月 12 日
Apply hiseq for each channel : example :
I=im2double(imread('autumn.tif'));
X=zeros(size(I));
for n=1:3
X(:,:,n)=histeq(I(:,:,n));
end
Image Analyst
Image Analyst 2013 年 10 月 13 日
No offense, but do you like what histeq does? I find it gives unrealistic and unnatural looking images. Even a primitive contrast stretch like imadjust() will give more pleasing images than histeq(). I think histeq is just in there for instructional purposes but I doubt anyone in real world situations considers it a good thing to do. A gamma like she tried will probably look okay but that just adjusts intensity. Some of the better filters do that plus do spatial frequency enhancements to see details better.
Youssef  Khmou
Youssef Khmou 2013 年 10 月 13 日
I agree, but it may work for X ray images, waiting for her answer..
Christine Ak
Christine Ak 2013 年 10 月 13 日
actually it doesn't work with X-rays...... My purpose is to enhance the contrast in the heel effect of the image the problem in the image is that the light distributed ((not)) equally at the sides
Christine Ak
Christine Ak 2013 年 10 月 13 日
Thankk You Guys 4 ur help... I found out the error it was in the second for loop...it must be
for i=1:n1
corrected(:,i)=h(:,i)/(A*(i.^Gama));
end

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

カテゴリ

質問済み:

2013 年 10 月 12 日

コメント済み:

2020 年 6 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by