Error : Incomplete or misformed expression or statement.

조회 수: 5 (최근 30일)
Gaurav
Gaurav 2014년 1월 26일
댓글: Gaurav 2014년 1월 27일
Error : Incomplete or misformed expression or statement. Line: 4 Column: 6
CODE : A function that creates overlapping blocks of same size from an image
function [blocks,val1,val2]=frame2OverlappingBlocks(I,blockSize,shift)
if blockSize(1)>=shift
[n_row,n_col] = size(I);
%check the dimension consistency
[~,pos1,val1]=find((((1:shift:n_row) + blockSize(1)-1)>=n_row).*((1:shift:n_row) + blockSize(1)-1),1);
[~,pos2,val2]=find((((1:shift:n_col) + blockSize(2)-1)>=n_col).*((1:shift:n_col) + blockSize(2)-1),1);
I = imresize(I,[val1 val2]);
%[n_row_new,n_col_new] = size(I);
blocksPerRow = pos2;
howManyRows = pos1;
blocks = cell(howManyRows,blocksPerRow);
for i=1:howManyRows
for j=1:blocksPerRow
topLeftPel = [shift*i-(shift-1) shift*j-(shift-1)];
blocks{i,j}.intensity = I(topLeftPel(1):topLeftPel(1)+blockSize(1)-1,topLeftPel(2):topLeftPel(2)+blockSize(2)-1);
blocks{i,j}.topLeftPixel = topLeftPel;
end
end
else
display('Amount of shift is greater than the Block size!!');
end
end
  댓글 수: 2
Walter Roberson
Walter Roberson 2014년 1월 26일
Which MATLAB version are you using? If you are using R2008b or earlier, try replacing the ~ with the name of an otherwise unused variable.
Gaurav
Gaurav 2014년 1월 26일
Using MATLAB 7

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

채택된 답변

Walter Roberson
Walter Roberson 2014년 1월 27일
Change
[~,pos1,val1]=find((((1:shift:n_row) + blockSize(1)-1)>=n_row).*((1:shift:n_row) + blockSize(1)-1),1);
[~,pos2,val2]=find((((1:shift:n_col) + blockSize(2)-1)>=n_col).*((1:shift:n_col) + blockSize(2)-1),1);
to
[UnusedVariable1,pos1,val1]=find((((1:shift:n_row) + blockSize(1)-1)>=n_row).*((1:shift:n_row) + blockSize(1)-1),1);
clear UnusedVariable1
[UnusedVariable2,pos2,val2]=find((((1:shift:n_col) + blockSize(2)-1)>=n_col).*((1:shift:n_col) + blockSize(2)-1),1);
clear UnusedVariable2

추가 답변 (0개)

카테고리

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