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:

Answers (1)

[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 Comments

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
Thank you! It worked!

Sign in to comment.

Asked:

on 24 Jun 2021

Commented:

on 25 Jun 2021

Community Treasure Hunt

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

Start Hunting!