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

2 Ansichten (letzte 30 Tage)
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)

Akzeptierte Antwort

Image Analyst
Image Analyst am 21 Jan. 2018
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');

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by