フィルターのクリア

Unable to perform assignment because the size of the left side is 1-by-512 and the size of the right side is 1-by-3. Error in A5 (line 43) empty(position,:) = [xn yn Image(xn,yn)]; PLEASE HELP ME TO SOLVE THIS ERROR

1 回表示 (過去 30 日間)
clc;
close all;
%% Read Input Image - peppers_gray
Oimage=imread('peppers_gray.tif');
[M,N]=size(Oimage);
Image=Oimage(:,1:N/2);
figure(1);imshow(Image);
title('Input Image - Peppers','Color','red');
%% Selecting Seed Pixel from Input Image
figure(2),
imshow(Image, []);
[y,x,button]= ginput(1);
y = round(y);
x = round(x);
[M,N]=size(Image);
%%
%[M,N]=size(Image);
%Image=Oimage(:,1:N/2);
threshold = 13
segmentedimage = zeros(size(Image));
% 8-neighbors
nhood = [-1 -1; -1 0; -1 1; 0 -1; 0 1; 1 -1; 1 0; 1 1];
pdist = 0;
seed = Image(x,y);
reg_size = 1;
position = 0;
% some space to save co-ordinates and values of neighbors
empty = zeros(M,N);
while (pdist<threshold && reg_size<numel(Image))
for ix = 1:8
% gives the co-ordinates of the 8 neighbors
xn = x + nhood(ix,1);
yn = y + nhood(ix,2);
ins=(xn>=1)&&(yn>=1)&&(xn<=M)&&(yn<=N);
if(ins&&segmentedimage(xn,yn)==0)
position = position+1;
empty(position,:) = [xn yn Image(xn,yn)];
segmentedimage(xn,yn)=1;
end
end
% calculate the mean of the 8 connected pixel and and add the
% co-ordinates into x,y
dist = abs((empty(1:position,3)) - (seed));
[pdist, index] = min(dist);
segmentedimage(x,y)=2; reg_size=reg_size+1;
seed= (seed*reg_size + empty(index,3))/(reg_size+1);
x = empty(index,1); y = empty(index,2);
%delete the empty stuff
empty(index,:) = empty(position,:); position=position - 1;
end
segmentedimage = segmentedimage > 1;
  1 件のコメント
darova
darova 2019 年 11 月 5 日
Any connection between these lines?
empty = zeros(M,N);
empty(position,:) = [xn yn Image(xn,yn)];

サインインしてコメントする。

回答 (0 件)

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by