How to enchant image using histeq?

2 ビュー (過去 30 日間)
Nanda Sulthan Estupratama
Nanda Sulthan Estupratama 2018 年 6 月 24 日
I have a code :
image=imread('geranium.jpg');
figure
imshow(image)
imR1=image(:,:,1);
imG1=image(:,:,2);
imB1=image(:,:,3);
gray = uint8(0.299*double(imR1) + 0.587*double(imG1) + 0.114*double(imB1));
%opening operation
di = strel('line',50,100);
dilate = imdilate(gray,di);
er = strel('line',50,100);
erode = imerode(dilate,er);
%difference image between opening operation and grayscale
difference_image = double(gray) - double(erode);
figure; % Open up another figure window.
subplot (2,2,1)
imshow(dilate)
subplot (2,2,2)
imshow(erode)
subplot(2,2,3)
imshow(difference_image, []); % Display the difference image.
the difference_image's variable result is
what should I do to enchant the difference_image into this figure below?
I have tried histeq, but the result is all black

採用された回答

Image Analyst
Image Analyst 2018 年 6 月 24 日
It's a BAD idea to call your image variable "image" because that is the name of a built-in function.
Simply linearly stretch the image with mat2gray():
outputImage = uint8(255 * mat2gray(grayImage));
Histogram equalization gives crummy, unnatural looking images and I always avoid it unless forcefully asked by students who need it for their homework. In the real world I don't think any good image analysts use it because (1) it's not necessary, and (2) it gives lousy looking images.
  3 件のコメント
Image Analyst
Image Analyst 2018 年 6 月 24 日
You can sharpen with a convolution
kernel = [-1,-1,-1; -1,17,-1; -1,-1,-1] / 9;
sharpImage = conv2(double(grayImage), kernel, 'same');
imshow(sharpImage, []);
Nanda Sulthan Estupratama
Nanda Sulthan Estupratama 2018 年 6 月 24 日
thank you very much for your assistance. I really appreciate your kindness

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by