how can i divide green hl component in blocks using function in matlab??

1 view (last 30 days)
My project is on digital color image watermarking!!the size of image that i use as cover image is 512*512. for embedding purposr first i apllly 2 level dwt and the i want to to divide green hl2 component into 4 blocks.the code is here.
this statment is use for calling the thefunction
[ upperHalfA1,lowerHalfA1,upperHalfA2,lowerHalfA2 ] = Dividev2( hl2);
/// where division code is here. ////
function [ upperHalf1,lowerHalf1,upperHalf2,lowerHalf2 ] = Dividev2( A)
%UNTITLED4 Summary of this function goes here
% Detailed explanation goes here
% obtain size of image.
[rows, columns] = size(A); middleColumn = int32(columns/2); middleRow = int32(rows/2); % Split them up.
upperHalf1 = A(1:middleRow, 1:middleColumn);
lowerHalf1=A( middleRow+1:end,1:middleColumn); % Display them.
% subplot(2, 2, 1);
% imshow(upperHalf1);
% title('Upper Left Half', 'FontSize', 15);
% subplot(2, 2, 3);
% imshow(lowerHalf1);
% title('Lower Left Half', 'FontSize', 15);
upperHalf2 = A(1:middleRow, middleColumn+1:end);
% subplot(2, 2, 2);
% imshow(upperHalf2);
% title('Upper Right Half', 'FontSize', 15);
lowerHalf2=A( middleRow+1:end, middleColumn+1:end);
% subplot(2, 2, 4);
% imshow(lowerHalf2);
% title('Lower Right Half', 'FontSize', 15);
%reB=[upperHalf1,upperHalf2];
%reA=[lowerHalf1,lowerHalf2];
%RECnst=[reB;reA]; %figure %imshow(RECnst)
end but this code gives wrong size
please help me how can i divide green HL2 component in four blocks on matlab.
  2 Comments
Michael Haderlein
Michael Haderlein on 6 May 2015
What is going on here? You use the exactly same words as used in this question, however, under a different user name. Did you just create a second account to ask the very same question again? It would be better to keep working in the other thread and say what the problems are instead of posting the same thing multiple times plus wasting your time with creating new accounts.
Walter Roberson
Walter Roberson on 6 May 2015
What do you mean by "gives wrong size" ? What does size(A) show up as, and what does size() of the quarters show up as?

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 8 May 2015
The image you are passing in is 3 dimensional. When you use size() and request fewer output variable than the array has dimensions, size() returns all the remaining dimensions multiplied together. The third dimension happens to have 3 planes so your columns variable will be 3 times as big as you expect.
You need to recode to take the third dimension into account.
  3 Comments
shameen khan
shameen khan on 11 May 2015
respected sir! i am sending you a full code. the problem is that extra black space block of 192 size(which is not required) is being added to our required block of 64!.. we just need the block of 64*64 and we are getting an image of 64*192(which we do not require).

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!