delete zeros rows and columns

조회 수: 5 (최근 30일)
Isee You
Isee You 2012년 3월 1일
i try do delete rows and columns that are zeros but it cut also part of shape .I use this code
u=I;
old=[];
new=all(~u);
while ~isequal(old,new)
u(new,:)=0;
old=new;
new=all(~u);
end
u(new,:)=[];
u(:,new)=[];
av=u;
av(~any(u,2),:)=[];
%radious of puple
figure, imshow(av,[]);
so any other way to do that

채택된 답변

Jonathan Sullivan
Jonathan Sullivan 2012년 3월 2일
u = I;
zc = ~any(u);
u(:,zc) = [];
zr = ~any(u,2);
u(zr,:) = [];
  댓글 수: 1
Isee You
Isee You 2012년 3월 2일
thank u "Jonathan Sullivan"

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Walter Roberson
Walter Roberson 2012년 3월 1일
u = I;
zc = ~any(u);
zr = ~any(u,2);
u(zc,zr) = [];
imshow(u, []);
  댓글 수: 1
Isee You
Isee You 2012년 3월 2일
i try this code but i get this error
Subscripted assignment dimension mismatch.
Error in first_step_to_final (line 110)
u(zc,zr) = [];
why? how to solve it

댓글을 달려면 로그인하십시오.


Andrea
Andrea 2012년 5월 30일
data( all( ~any( data), 2 ), : ) = []; % removes all rows with all zero
data( :, all( ~any( data ), 1 ) ) = []; % and columns

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by