''Error using reshape: To RESHAPE the number of elements must not change''

in image one you can say it is showing no error ,but in second image (b.img) it is showing ,error . why this is happening?

 채택된 답변

Use this:
[rows, columns, numberOfColorChannels] = size(I);
F = reshape(I, rows*columns, numberOfColorChannels);

댓글 수: 5

thanks a lot sir ,it worked
Thanks sir a lot
my code has same problem of RESHAPE :
k=50; % set minimum coeff difference
blocksize=8; % set the size of the block in cover to be used for each bit in watermark
% read in the cover object
file_name='lena.png';
cover_object=double(imread(file_name));
% determine size of cover image
Mc=size(cover_object,1); %Height
Nc=size(cover_object,2); %Width
% determine maximum message size based on cover object, and blocksize
max_message=Mc*Nc/(blocksize^2);
% read in the message image
file_name='copyright2.png';
message=double(imread(file_name));
Mm=size(message,1); %Height
Nm=size(message,2); %Width
% reshape the message to a vector
message=fix(reshape(message,Mm*Nm,1)/2);
error is `Error using reshape :To RESHAPE the number of elements must not change. Error in dct1_embed (line 32) message=fix(reshape(message,Mm*Nm,1)/2);` . what i will change in code to execute that code? Thanks in advance!!!
hello Bhanveet,
Did you find out the solution of this error? because I am also getting the same error and I am also working on watermarking.
The image array called "message" is most likely color. Use rgb2gray() to cast it to gray scale.

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

추가 답변 (1개)

Benjamin Kraus
Benjamin Kraus 2017년 12월 27일

0 개 추천

What is the size of I both before and after calling imresize on the second image? Is one of the images grayscale or black and white? If so, it is possible the third dimension of the image is 1 instead of 3.

댓글 수: 1

1. 256 256. 2. image is attached . GADOimage.jpg 3. what is the difference between 1 & 3 in third dimension of the image. when i will come to know if it is 1 or 3

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

태그

질문:

2017년 12월 27일

댓글:

2019년 10월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by