High pass butterworth filter
이전 댓글 표시
I have written a code for implementing High Pass Butter Worth Filter. However, on running the code, I am constantly getting the same error as attached below. I have used parentheses and it still shows the same error. I am unable to understand and rectify it. Kindly help with the same.
Code:
clc;
clear all;
close all;
img=imread('Cameraman.jpg');
hb=butterhp(img,15,1);
hb=butterhp(img,15,1);
af=fftshift(fft2(img)); %FT
fftshow(af);
afhb=af.*hb; %Convolution with ButterWorth Filter
fftshow(afhb);
Function File:
function [out] = butterhp(im,d,n) %wc=cut off frequency and n=order
%UNTITLED4 Summary of this function goes here
% Detailed explanation goes here
h=size(im,1);
w=size(im,2);
[x,y]=meshgrid(-floor(w/2):floor(w-1)/2; -floor(h/2):floor(h-1)/2);
out=1./(1.+(d./x.^2+y.^2).^0.5).^(2*n));
end
Error:

답변 (1개)
Walter Roberson
2021년 6월 24일
[x,y]=meshgrid(-floor(w/2):floor(w-1)/2; -floor(h/2):floor(h-1)/2);
^
You cannot use ; to separate parameters. You can only use ; inside [] and {} (and, of course, in quoted strings and comments.)
댓글 수: 3
Jake Cooper
2021년 6월 24일
You had an extra ) in the assignment to out ... but you almost certainly were missing a ( in the same assignment, so the ) was probably correct.
im = imread('cameraman.tif');
out = butterhp(im, 100, 7);
imagesc(uint8(out))
function [out] = butterhp(im,d,n) %wc=cut off frequency and n=order
%UNTITLED4 Summary of this function goes here
% Detailed explanation goes here
h=size(im,1);
w=size(im,2);
[x,y]=meshgrid(-floor(w/2):floor(w-1)/2, -floor(h/2):floor(h-1)/2);
out=1./(1.+(d./(x.^2+y.^2).^0.5).^(2*n));
end
Jake Cooper
2021년 6월 25일
카테고리
도움말 센터 및 File Exchange에서 Butterworth에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
