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
Walter Roberson 2021년 6월 24일

0 개 추천

[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
Jake Cooper 2021년 6월 24일
I changed this, the error still remains
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
Jake Cooper 2021년 6월 25일
Thank you! It worked!

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

질문:

2021년 6월 24일

댓글:

2021년 6월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by