after if condition the value is not assigning, the default value 255 is coming
1 view (last 30 days)
Show older comments
Datti Nagadhara Harini
on 9 Jan 2014
Commented: Datti Nagadhara Harini
on 2 Apr 2014
% seeded region growing algorithm %
clear all; clc;
I = imread('7.jpg');
Is = imresize(I,[256 256]);
Ig = rgb2gray(Is);
impixelinfo(imshow(Ig));
% determine how many clusters for an image %
c1 = 300; c2 = 500; c3 = 600;
%determine how many seed points u reqire%
p1 = 228;
p2 = 198;
p3 = 100;
%difference of pixel values of seed point to neighbouring pixels%
for i =1:256
for j =1:256
if abs(p1 - Ig(i,j)) <= 5
Ig(i,j) = 300;
elseif abs(p2 -Ig(i,j)) <= 5
Ig(i,j) = 600;
else
Ig(i,j) = 700;
end
end
end
0 Comments
Accepted Answer
Image Analyst
on 9 Jan 2014
This is not seed growing - nothing is growing. You are quantizing, which you can do like this without a loop
outputImage = 700 * ones(256,256, 'uint32'); % Initialize to all 700.
binaryImage = Ig >= (p1-5) & Ig <= (p1+5);
outputImage(binaryImage) = 300;
binaryImage = Ig >= (p2-5) & Ig <= (p2+5);
outputImage(binaryImage) = 600;
I have no idea where 255 is coming from - you don't even have a 255 in your code at all!
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!