【发布时间】:2015-01-27 11:16:42
【问题描述】:
我想在每列中找到第一个和最后一个蓝色像素,然后他们在之前实现的这些行内找到另一个边界(第一个和最后一个蓝色像素行)。
我根据之前的答案进行了更改,但现在在尝试查找 bif_first 和 last 时出现此错误:下标分配维度不匹配。 bif_first2(2,z)=find(dx(:,z)==1,2,'first');
怎么了?请参阅下面的代码:
rgbImage_blue=zeros(size(movingRegistered));
lumen_first=zeros(1,size(movingRegistered,2)); lumen_last=zeros(1,size(movingRegistered,2)); bif_first=zeros(1,size(movingRegistered,2)); bif_last=zeros(1,size(movingRegistered,2)); bif_last2=zeros(2,size(movingRegistered,2)); bif_first2=zeros(2,size(movingRegistered,2));
blue=cat(3,0,0,255);
ix=all(bsxfun(@eq,movingRegistered,blue),3);% find all the blue pixels, and put them at 1 % logical array of where blue pixels are dx=[zeros(1,size(movingRegistered,2));diff(ix)]; % zeros to make the same number of columns and rows % the difference by row for all columns
nTops=sum(dx==1); % the transitions to blue
nBots=sum(dx==-1); % and from blue... % see if are consistent; if not, something's not right in image
if(nTops~=nBots), error('Mismatch in Top/Bottom'),end
for z=1:1:size(movingRegistered,2);
if nTops(1,z)==2; bifurcation=false;lumen=true; %only existis two boundaries no bifurcation
lumen_first(1,z)=find(ix(:,z)==1,1,'first');
lumen_last(1,z)=find(ix(:,z)==1,1,'last');
end
if nTops(1,z)>2;
bifurcation=true;
lumen_first(1,z)=find(ix(:,z)==1,1,'first');
lumen_last(1,z)=find(ix(:,z)==1,1,'last');
bif_first2(2,z)=find(dx(:,z)==1,2,'first');
bif_first(1,z)=bif_first2(2,z);
bif_last2(2,z)=find(dx(:,z)==1,2,'last');
bif_last(1,z)=bif_last2(2,z);
end
end
【问题讨论】:
-
试试
ix=(movingRegistered(:,:,1)==blue(1))&(movingRegistered(:,:,2)==blue(2))&(movingRegistered(:,:,3)==blue(3)) -
blue未定义为[0 0 255].'的任何原因? -
是的 255 是我的错!!
-
请不要使用@Daniel 提供的答案来编辑您的问题,因为这是一个完全不同的问题!如果答案解决了您的问题,请将其标记为已接受,如果有其他问题,请提出另一个问题。