Subscript indices must either be real positive integers or logicals.

조회 수: 3 (최근 30일)
Kiruba Raji.I
Kiruba Raji.I 2016년 8월 19일
편집: Image Analyst 2016년 8월 20일
Error in imcut NewIm = Image( (cr - 63):(cr + 64),(cc - 63):(cc + 64) );
Error in pcn1 xo = imcut(xr); subplot(6, 3, 3*rt+9*(sc-1)-2), imshow(xo)
pcn1.m
clear,close all,
addpath('functions\');
addpath('images\')
x = imread('d:\segleaf\i1.jpg');
figure,
for sc =1:2
xs = imresize(x,0.2*sc+0.6);
for rt = 1:3
xr = imrotate(xs,rt*30-30,'bilinear','crop');
xo = imcut(xr);
subplot(6, 3, 3*rt+9*(sc-1)-2),
imshow(xo)
h = imhist(xo);
subplot(6, 3, 3*rt+9*(sc-1)-1),
plot(h), xlim([0, 256])
set(gca,'xtick',[],'xticklabel',[]);
set(gca,'ytick',[],'yticklabel',[]);
ts = SCM(xo);
subplot(6, 3, 3*rt+9*(sc-1)),
plot(ts),
ylim([0, 5000])
set(gca,'xtick',[],'xticklabel',[]);
set(gca,'ytick',[],'yticklabel',[]);
end
end
imcut.m
[r,c] = size(Image);
cc = floor(c/2);
cr = floor(r/2);
NewIm = Image( (cr - 63):(cr + 64),(cc - 63):(cc + 64) );
NewIm=logical(NewIm);
  댓글 수: 2
James Tursa
James Tursa 2016년 8월 19일
This is difficult to read. Can you please format it with the { } Code button to make it readable?
per isakson
per isakson 2016년 8월 20일
I cannot reproduce the problem you report. See Debug a MATLAB Program

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

답변 (2개)

Walter Roberson
Walter Roberson 2016년 8월 20일
You are reading a JPEG. That is highly likely an RGB image rather than a grayscale image. Using
[r,c] = size(Image);
for an RGB image is almost always a mistake.
[d1,d2,d3,...,dn] = size(X), for n > 1, returns the sizes of the dimensions of the array X in the variables d1,d2,d3,...,dn, provided the number of output arguments n equals ndims(X). If n does not equal ndims(X), the following exceptions hold:
n < ndims(X)
di equals the size of the ith dimension of X for 0<i<n, but dn equals the product of the sizes of the remaining dimensions of X, that is, dimensions n through ndims(X).

Image Analyst
Image Analyst 2016년 8월 20일
편집: Image Analyst 2016년 8월 20일
It says you're doing this:
xo = imcut(xr);
Yet your definition of imcut in imcut.m does not have a function line so how are you going to pass in xr?

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by