I have following code and above stated error I am getting,
if true% Global Thresholding of an unsuitable image. In comparison, the same
% image is thresholded in an Adaptive manner.
clear all;% load ball;
Image= imread('cameraman.tif');Image=Image(:,:,1);clear ball;% Display the original image (normalized to the range 0-64)
figure;colormap(gray);image(round(Image/4));title('(a) The Original image');% Display the Gray-level Distribution Histogram
Min= min(min(Image));Max= max(max(Image));Min=double(Min);Max=double(Max);figure;hist(Image, (Min):(Max));title('(b) Gray-level Distribution Histogram');% Perform Global thresholding with a threshold of 130
Tg= 130;GlobalThresholded= (255 * (Image > Tg));figure;colormap(gray);image(GlobalThresholded);title('(c) Globally Thresholded image, Tg=130');% Perform an Adaptive Thresholding: average over a neighborhood of 61x61
[M, N]= size(Image);AverageMask= ones(61, 61) / (61^2);Threshold= conv2(Image, AverageMask);ThresholdMask= (Image - (Threshold(31:M+30, 31:N+30)) + 6);<--------- here is the errorAdaptiveThresholded= 255 * (ThresholdMask > 0);figure;colormap(gray);image(AdaptiveThresholded);title('(d) Adaptive Thresholded Image'); % code
end
Somebody please Suggest me Whats wrong here, please give me reasons because I got it many times,
Thanks
Best Answer