what is the most effective way of using laplacian filter
조회 수: 14 (최근 30일)
이전 댓글 표시
How is this laplacian filter(in code) more effective than this la = [0 1 0;1 -4 1;0 1 0]; m = imfilter(rgb_2_gray, la); sharp = rgb_2_gray - m
imagePath = 'ball.png';
originalImage = imread(imagePath);
% Display the original image
figure('Name', 'Image Processing Steps');
subplot(2, 3, 1);
imshow(originalImage);
title('Original Image');
% Apply Laplacian filter
laplacianFilter = fspecial('laplacian');
laplacianImage = imfilter(originalImage, laplacianFilter, 'replicate');
subplot(2, 3, 2);
imshow(laplacianImage, []);
title('Laplacian Filtered Image');
% Subtract Laplacian filter to display sharpened image
sharpenedImage = originalImage - laplacianImage;
subplot(2, 3, 3);
imshow(sharpenedImage);
title('Sharpened Image');
% Apply Sobel filter
sobelFilter = fspecial('sobel');
sobelImage = imfilter(originalImage, sobelFilter, 'replicate');
subplot(2, 3, 4);
imshow(sobelImage);
title('Sobel Filtered Image');
% Smooth image by a 5x5 averaging filter
averageFilter = fspecial('average', [5 5]);
smoothedImage = imfilter(originalImage, averageFilter, 'replicate');
subplot(2, 3, 5);
imshow(smoothedImage);
title('Smoothed Image');
% Apply power law to smoothed image
gamma = 0.5; % Power law exponent (you can adjust this value)
powerLawImage = imadjust(smoothedImage, [], [], gamma);
subplot(2, 3, 6);
imshow(powerLawImage);
title('Power Law Image');
댓글 수: 1
답변 (1개)
DGM
2023년 7월 8일
편집: DGM
2023년 7월 8일
FWIW, you can change the shape parameter for the laplacian kernel. Default is 0.2. Why is that the default? I don't know.
fk = fspecial('laplacian',0)
fk = fspecial('laplacian',0.5)
fk = fspecial('laplacian',1)
In all cases, the overall sum is zero. The sum across any edge vector is 1, and the sum across the center is -2.
... but look at the difference across any central vector. As alpha increases, the difference decreases. It should stand to reason then that when alpha is zero, you'll get the strongest response to image edges. (i think that's what you're asking)
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!