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

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

回答(2 个)

James Tursa
James Tursa 2014-11-6
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 个评论
vaishali
vaishali 2014-11-6
编辑:James Tursa 2014-11-6
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);
James Tursa
James Tursa 2014-11-6
What is size(message)? In particular, what is size(message,3)?

请先登录,再进行评论。


Roger Stafford
Roger Stafford 2014-11-6
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'.

类别

Help CenterFile Exchange 中查找有关 Geometric Transformation and Image Registration 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by