Error in mat2cell because of the size of the image have anyone solution for that?

2 ビュー (過去 30 日間)
Ameligege
Ameligege 2015 年 4 月 21 日
コメント済み: Ameligege 2015 年 4 月 21 日
rgbImage = imread('image.jpg');
[rows, columns , numberOfColorBands] = size(rgbImage);
Greenlayer = rgbImage(:,:,2);
blockSizeR = 8;
blockSizeC = 8;
wholeBlockRows = floor(rows / blockSizeR);
blockVectorR = [blockSizeR * ones(1, wholeBlockRows), rem(rows, blockSizeR)];
wholeBlockCols = floor(columns / blockSizeC);
blockVectorC = [blockSizeC * ones(1, wholeBlockCols), rem(columns, blockSizeC)];
ca = mat2cell(Greenlayer, blockVectorR, blockVectorC);
when I run this code with image of size 512*384 It works ,but if I run it on other size the following error occur have anyone any idea for the solution of this problem please and here is the error msg
Error using mat2cell (line 107)
Input arguments, D1 through D2, must sum to each dimension of the input
matrix size, [1648 2336].'
ca = mat2cell(Greenlayer, blockVectorR, blockVectorC);
thanks...

回答 (1 件)

Image Analyst
Image Analyst 2015 年 4 月 21 日
You're doing it on a 3D full color image - that's why it says that. You should probably do it one color channel at a time. If you do that it should not complain.
  3 件のコメント
Image Analyst
Image Analyst 2015 年 4 月 21 日
I just ran it with a grayscale 1648 x 2336 image and there was no error at all.
Ameligege
Ameligege 2015 年 4 月 21 日
you are right , When I ran it in separate script it ran ,but with the rest of the code this error occur I will check the rest of the code to see where the problem is.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by