How do I use IMFILTER to high pass filter an image?

조회 수: 63 (최근 30일)
Sonoma Rich
Sonoma Rich 2011년 8월 5일
댓글: DGM 2022년 4월 27일
How can I high pass filter an image (A) using IMFILTER(A,H)? What must the filter matrix (H) be to perform a high pass filter?

채택된 답변

Ashish Uthama
Ashish Uthama 2011년 8월 5일
This tutorial might help.
  댓글 수: 5
Image Analyst
Image Analyst 2022년 4월 27일
It looks like the tutorial is no longer online. The link to the course is:

댓글을 달려면 로그인하십시오.

추가 답변 (3개)

Image Analyst
Image Analyst 2011년 8월 6일
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures.
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
fontSize = 20;
% Read in a standard MATLAB gray scale demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
baseFileName = 'cameraman.tif';
fullFileName = fullfile(folder, baseFileName);
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
if ~exist(fullFileName, 'file')
% Didn't find it there. Check the search path for it.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
grayImage = imread(fullFileName);
% Get the dimensions of the image. numberOfColorBands should be = 1.
[rows columns numberOfColorBands] = size(grayImage);
% Display the original gray scale image.
subplot(2, 2, 1);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Position', get(0,'Screensize'));
set(gcf,'name','Demo by ImageAnalyst','numbertitle','off')
% Filter 1
kernel1 = -1 * ones(3)/9;
kernel1(2,2) = 8/9
% Filter the image. Need to cast to single so it can be floating point
% which allows the image to have negative values.
filteredImage = imfilter(single(grayImage), kernel1);
% Display the image.
subplot(2, 2, 2);
imshow(filteredImage, []);
title('Filtered Image', 'FontSize', fontSize);
% Filter 2
kernel2 = [-1 -2 -1; -2 12 -2; -1 -2 -1]/16;
% Filter the image. Need to cast to single so it can be floating point
% which allows the image to have negative values.
filteredImage = imfilter(single(grayImage), kernel2);
% Display the image.
subplot(2, 2, 3);
imshow(filteredImage, []);
title('Filtered Image', 'FontSize', fontSize);
  댓글 수: 2
Ashish Uthama
Ashish Uthama 2011년 8월 8일
+1, tagging as a tutorial
Image Analyst
Image Analyst 2011년 10월 12일
I've never heard of filter1. imfilter and filter2 should give the same answer.

댓글을 달려면 로그인하십시오.


Tony
Tony 2011년 8월 9일
A typical high-pass (or high emphasize filter) would be an unsharp mask.
H = fspecial('unsharp');

Pramod Bhat
Pramod Bhat 2011년 8월 25일
Simple averaging your image can fulfill your need if u are not particular with the pass band.

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by