Histogram and automatic thresholding
古いコメントを表示
Hello everyone, sorry for requesting another. Really new to imaging.
I have perform the normalized gradient magnitude. Also found the histogram of it. But I wish to apply an authomatic thresholding technique based on the histogram of the normalized gradient magnitude. All edge map pixel with values greater than the threshold retains their original values, while those edge map pixels with values less than the threshold had their values set to zero.
please find my code;
im=dicomread('Image');
%applying sobel filtering
P1=fspecial('sobel');
P2=P1;
Data1=imfilter(im,P1,'replicate');
Data2=imfilter(im,P2,'replicate');
% gradient magnitude
grad=sqrt((Data1.^2)+(Data2.^2));
figure,imshow(grad,[]);
%%Normalize the Image:
myImg=grad;
myRange = getrangefromclass(myImg(1));
newMax = myRange(2);
newMin = myRange(1);
myImgNorm = (myImg - min(myImg(:)))*(newMax - newMin)/(max(myImg(:)) -
min(myImg(:))) + newMin;
figure,imshow(myImgNorm,[]);
%%calculating the histogram of normalized gradient
bin=255;
imhist(double(myImgNorm(:)),bin);
%figure,plot(h);
The next step I need your help is:
To perform the automatic threshold based on the histogram of the normalized gradient magnitude.
input image=Normalized gradient magnitude.
Thank you for your help in advance.
Regards,
3 件のコメント
Matt J
2013 年 11 月 8 日
It would help if you format your code in a separate font from your text using the

formatting button. This would make the post more readable.
Josh
2013 年 11 月 8 日
Image Analyst
2013 年 11 月 8 日
You didn't do it correctly. Just format the code, not your comments. And get rid of empty lines between code. Then just highlight the code (only, no regular text from you) and click the {}Code button.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Image Filtering and Enhancement についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!