フィルターのクリア

after if condition the value is not assigning, the default value 255 is coming

1 回表示 (過去 30 日間)
% 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

採用された回答

Image Analyst
Image Analyst 2014 年 1 月 9 日
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!

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by