Subscript indices must either be real positive integers or logicals.

6 次查看(过去 30 天)
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 个)

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