How to do a 2D convolution result with the log operator for an Image.

1 回表示 (過去 30 日間)
Westin Messer
Westin Messer 2018 年 1 月 21 日
回答済み: Image Analyst 2018 年 1 月 21 日
Hi, I want to apply an LOG enhancement mask for image enhancement using conv2. The LOG enhancement mask to be convolved with the image is: h = [-1 -1 -1; -1 9 -1; -1 -1 -1]; So far this is the code I have but the image is not enhanced at all. Any help would be appricated.
image = imread('mdb001.jpg');
imshow(image);
h = [-1 -1 -1; -1 9 -1; -1 -1 -1]
grayimage= rgb2gray(image);
im=grayimage;
i=conv2(h,im);
figure()
imshow(i)

採用された回答

Image Analyst
Image Analyst 2018 年 1 月 21 日
That has nothing to do with log. That's a standard Laplacian high boost filter. Here, try this:
grayImage = imread('peppers.png');
imshow(grayImage);
% Get the dimensions of the image.
% numberOfColorChannels should be = 1 for a gray scale image, and 3 for an RGB color image.
[rows, columns, numberOfColorChannels] = size(grayImage);
if numberOfColorChannels > 1
% It's not really gray scale like we expected - it's color.
% Use weighted sum of ALL channels to create a gray scale image.
grayImage = rgb2gray(grayImage);
% ALTERNATE METHOD: Convert it to gray scale by taking only the green channel,
% which in a typical snapshot will be the least noisy channel.
% grayImage = grayImage(:, :, 2); % Take green channel.
end
% Display the image.
subplot(2, 1, 1);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', fontSize, 'Interpreter', 'None');
h = [-1 -1 -1; -1 9 -1; -1 -1 -1]
filteredImage = conv2(double(grayImage), h, 'same');
% Display the image.
subplot(2, 1, 2);
imshow(filteredImage, [0, 255]);
title('Filtered Image', 'FontSize', fontSize, 'Interpreter', 'None');

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Filtering and Enhancement についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by