Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Convert 4096 (8 X 8) image blocks into an image

603 views
Skip to first unread message

Krishna Prasad Satamraju

unread,
Dec 22, 2010, 1:29:07 PM12/22/10
to
Dear all, I'm working on watermarking of digital image. A portion of the code is shown here:

clc;
clear all;
close all;

start_time = cputime; %Starting Time of Execution

I = imread('lena.jpg');

[r, c]=size(I);
bs=8; % Block Size (8x8)
nob=(r/bs)*(c/bs); % Total number of 8x8 Blocks

% Dividing the Cover image into 8x8 Blocks
for i=1:(r/bs)
for j=1:(c/bs)
dctimg(:,:,kk+j)=dct2(I((bs*(i-1)+1:bs*(i-1)+bs),(bs*(j-1)+1:bs*(j-1)+bs)));
end
kk=kk+(r/bs);
end
size(dctimg) = 8 8 4096.
How can I get size(dctimg) = 512 X 512;
Please Help. thanks in advance.

Sean de

unread,
Dec 22, 2010, 1:43:04 PM12/22/10
to
"Krishna Prasad Satamraju" wrote in message <ietg1j$jf5$1...@fred.mathworks.com>...

doc reshape

but why not just use blkproc to do the whole thing for you?
doc blkproc

or even cell2mat->cellfun->mat2cell
?

ImageAnalyst

unread,
Dec 22, 2010, 2:41:47 PM12/22/10
to
On Dec 22, 1:29 pm, "Krishna Prasad Satamraju"

> size(dctimg) = 8  8 4096.
> How can I get size(dctimg) = 512 X 512;
> Please Help. thanks in advance.
--------------------------------
I don't know. How did you *want* to turn your 3D image into a 2D
image? I have no idea. Maybe summing, maybe reshaping, maybe just
building it up differently in the first place, I have no idea. I
don't even know why you created this 3D image in the first place
instead of doing what Sean suggested. Are you SURE you really need a
3D (8x8x4096) or 2D (512x512) image at all???

Jan Simon

unread,
Dec 22, 2010, 8:21:04 PM12/22/10
to
Dear Krishna,

Let me add my wild guessing also:

> > size(dctimg) = 8  8 4096.
> > How can I get size(dctimg) = 512 X 512;

% D = [8 x 8 x 4096]
D = reshape(D, 8, 8, 64, 64);
E = permute(D, [1, 3, 2, 4]);
F = reshape(D, 512, 512);

Perhaps, or perhaps not. Jan

Krishna Prasad Satamraju

unread,
Dec 23, 2010, 1:32:05 AM12/23/10
to
"Sean de " <sean.d...@nospamplease.umit.maine.edu> wrote in message <ietgro$ddj$1...@fred.mathworks.com>...
> Thanks for your response to my recent post related to Image watermark. You quoted use of blkproc. I request you to please go throough the code once and suggest me to come out of the problem. I attached matlab file of the program
My aim is to
1. divide image(512 X 512 lena.jpg) into blocks of 8X8,
2. then perform DCT on each block.
3. In the DCT, replace the midfrequency coefficients (we get 64 coefficients out of which I pick 9) with watermark image. (my watermark image is divided into 3X3 block)
4. After replacing, perform IDCT to get the watermarked image. If I use blkproc I get dct for the entire image and cannot access individual 8 X 8 blocks
That's why I followed the above method, where I can access each block individually
The dctimg is an array of 8X8 dct coefficients.
size(dctimg) = 8 8 4096
Now I have to combine the 4096 blocks of image into a single image and calculate inverse DCT on it.
Please suggest a solution thank you

ramya s

unread,
Jan 18, 2011, 10:30:09 AM1/18/11
to
i am doing steganography in the similar way,

My aim is to
1. divide image(512 X 512 lena.jpg) into blocks of 8X8,

2. then perform DCT on each block and find quantized DCT values..

3. modify the non zero DCT quantized values coefficients (we get only 6-9 coeff out of 64 coefficients) with secret message.

4. After modifying, perform IDCT to get the stego image.

If I use blkproc I get dct for the entire image and cannot access individual 8 X 8 blocks

please help me how to proceed with the 8x8 block.


> > > clc;
> > > clear all;
> > > close all;
> > >
> > > start_time = cputime; %Starting Time of Execution
> > >
> > > I = imread('lena.jpg');
> > >
> > > [r, c]=size(I);
> > > bs=8; % Block Size (8x8)
> > > nob=(r/bs)*(c/bs); % Total number of 8x8 Blocks
> > >
> > > % Dividing the Cover image into 8x8 Blocks
> > > for i=1:(r/bs)
> > > for j=1:(c/bs)
> > > dctimg(:,:,kk+j)=dct2(I((bs*(i-1)+1:bs*(i-1)+bs),(bs*(j-1)+1:bs*(j-1)+bs)));
> > > end
> > > kk=kk+(r/bs);
> > > end
> > > size(dctimg) = 8 8 4096.
> > > How can I get size(dctimg) = 512 X 512;

> My aim is to

eric paulraj

unread,
Mar 3, 2011, 4:21:03 AM3/3/11
to
"Krishna Prasad Satamraju" wrote in message <ietg1j$jf5$1...@fred.mathworks.com>...


HI, CAN I GET THE SOLUTION FOR DIVIDING THE 512X512 IMAGE INTO 8X8 BLOCK

eric paulraj

unread,
Mar 3, 2011, 4:22:08 AM3/3/11
to
"Krishna Prasad Satamraju" wrote in message <ietg1j$jf5$1...@fred.mathworks.com>...

Muhammad Imran

unread,
Jul 1, 2012, 4:55:06 AM7/1/12
to
ImageAnalyst <imagea...@mailinator.com> wrote in message <e249575d-0b6e-462e...@g26g2000vbi.googlegroups.com>...
Can any one tel that how we can use this code for Color images.

Rashid Jamal

unread,
Jan 5, 2015, 11:49:11 PM1/5/15
to
Hey Krishna !! Hi actually i am working in the area of data embedding in images. I have the same problem of handling the 8x8 blocks so can you please help me to find the dct and quantized coefficient of the 8x8 block of the image. if you have the code then kindly send me the codes. my id is nitk....@gmail.com
0 new messages