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

3 ビュー (過去 30 日間)
vaishali
vaishali 2014 年 11 月 6 日
回答済み: Roger Stafford 2014 年 11 月 6 日
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'.

Community Treasure Hunt

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

Start Hunting!

Translated by