Integers can only be combined with integers of the same class, or scalar doubles
Show older comments
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 error
AdaptiveThresholded= 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
2 Comments
Walter Roberson
on 11 May 2013
What is class(Image) ? What is class(Threshold) ? Are they both the same class of integer? Is one of them an integer class and the other is a non-scalar double ?
Muhammad Ali Qadar
on 12 May 2013
Edited: Muhammad Ali Qadar
on 12 May 2013
Accepted Answer
More Answers (0)
Categories
Find more on Display 2-D Images in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!