필터 지우기
필터 지우기

Error using mat2cell (line 89) Number of input vector arguments, 2, does not match the input matrix's number of dimensions, 3

조회 수: 1 (최근 30일)
clc; clear all; close all; image1=imread('C:\Users\dell pc\Pictures\mandrilll.jpg'); im1=imresize(image1,[256 256]); im2=im2uint8(im1); subplot(2,2,1); figure(1); imshow(im2);title('original image'); image2=stdfilt(im2); image3=im2uint8(image2); subplot(2,2,2); imshow(image3); title('standard deviation map'); level = graythresh(image3); s= im2bw(image3,level); subplot(2,2,3); imshow(s); title('binarized standard deviation map'); numBlkH = 4; numBlkW = 4;
%# compute size of each tile in pixels [imgH,imgW,~] = size(s); szBlkH = [repmat(fix(imgH/numBlkH),1,numBlkH-1) imgH-fix(imgH/numBlkH)*(numBlkH-1)]; szBlkW = [repmat(fix(imgW/numBlkW),1,numBlkW-1) imgW-fix(imgW/numBlkW)*(numBlkW-1)];
%# divide into tiles, and linearize using a row-major order C = mat2cell(s, szBlkH, szBlkW)'; C = C(:);
%# display tiles i subplots figure for i=1:numBlkH*numBlkW subplot(numBlkH,numBlkW,i), imshow( C{i} ) end image1=imread('C:\Users\dell pc\Pictures\mandrilll.jpg'); im1=imresize(im1,[256 256]); im2=im2uint8(im1); numBlkH = 4; numBlkW = 4;
%# compute size of each tile in pixels [imgH,imgW,~] = size(im2); szBlkH = [repmat(fix(imgH/numBlkH),1,numBlkH-1) imgH-fix(imgH/numBlkH)*(numBlkH-1)]; szBlkW = [repmat(fix(imgW/numBlkW),1,numBlkW-1) imgW-fix(imgW/numBlkW)*(numBlkW-1)];
%# divide into tiles, and linearize using a row-major order P = mat2cell(im2, szBlkH, szBlkW)'; P = P(:); %# display tiles i subplots for i=1:numBlkH*numBlkW subplot(numBlkH,numBlkW,i), imshow( P{i} ) end figure a=1;b=1; for i=1:16 c1(:,:,i)=cell2mat(C(i)); p1(:,:,i)=cell2mat(P(i)); sum1=sum(sum(c1(:,:,i))); t(:,:,i)=sum1/(64*64); if t < 0.85 poortext(:,:,a)=c1(:,:,i); poortext1(:,:,a)=im2double(p1(:,:,i)); a=a+1; else text(:,:,b)=c1(:,:,i); text1(:,:,b)=p1(:,:,i);
b=b+1;
end
end
for i=1:a-1
d=(poortext1(:,:,i));
subplot(4,4,i)
imshow(d);
title('poor-texture');
end
figure
for i=1:b-1
d1(:,:,i)=(text1(:,:,i));
d2=d1(:,:,i);
subplot(4,4,i)
imshow(d2);
title('texture');
end
could anyone help me to solve the error. thanks in advance.

채택된 답변

Walter Roberson
Walter Roberson 2016년 10월 25일
mat2cell has to be told how to split every dimension. You are splitting rgb images and those are 3 dimensional so you have to tell mat2cell how to process the third dimension. If you do not want to split along the third dimension then add an additional argument which is the size of the third dimension.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by