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

조회 수: 4 (최근 30일)
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 CenterFile Exchange에서 Image Filtering and Enhancement에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by