Error using round(resh​ape(messag​e,Mm*Nm,1)​./256)

Hello,
What may be the problem with the following code line?
message=round(reshape(message,Mm*Nm,1)./256); using this I want to check message isn't too large to fit in cover image.
Where message=double(imread('lena.jpg')) and [Mm Nm] is the size of the message.
Thanks in advance

Answers (2)

What does the error message say?
Double check the size of the variable message to make sure it really is Mm x Nm.
Note that you can replace reshape(message,Mm*Nm,1) with message(:)

2 Comments

Thank you for your fast response .
The error says "To RESHAPE the number of elements must not change."
And this is the code segment
close all;
clear;
cover = imread('cheeta.jpg');
[a1 h1 v1 d1] = dwt2(cover,'haar');
[a2 h2 v2 d2] = dwt2(h2,'haar');
k=50; % set minimum coeff difference
blocksize=8; % set the size of the block in cover to be used for each bit in watermark
cover_object=h2;
%figure,imshow(cover);title('Original'); % determine size of cover image
Mc=size(cover_object,1); %Height
Nc=size(cover_object,2);
% determine maximum message size based on cover object, and blocksize
max_message=Mc*Nc/(blocksize^2); % read in the message image
msg='lena.jpg';
message=double(imread(msg));
Mm=size(message,1); %Height
Nm=size(message,2); %Width % reshape the message to a vector
message=round(reshape(message,Mm*Nm,1)./256);
What is size(message)? In particular, what is size(message,3)?

Sign in to comment.

Does 'lena.jpg' produce a third dimension for color? If so, that would account for your error message; you would have more than Mm*Nm elements in 'message'.

Categories

Asked:

on 6 Nov 2014

Answered:

on 6 Nov 2014

Community Treasure Hunt

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

Start Hunting!