How to do a 2D convolution result with the log operator for an Image.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Westin Messer
am 21 Jan. 2018
Beantwortet: Image Analyst
am 21 Jan. 2018
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)
0 Kommentare
Akzeptierte Antwort
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');
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Filtering and Enhancement finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!