Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Convert 4096 (8 X 8) image blocks into an image

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

From: Krishna Prasad Satamraju

Date: 22 Dec, 2010 18:29:07

Message: 1 of 10

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.

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

From: Sean de

Date: 22 Dec, 2010 18:43:04

Message: 2 of 10

"Krishna Prasad Satamraju" wrote in message <ietg1j$jf5$1@fred.mathworks.com>...
> 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.

doc reshape

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

or even cell2mat->cellfun->mat2cell
?

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

From: ImageAnalyst

Date: 22 Dec, 2010 19:41:47

Message: 3 of 10

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???

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

From: Jan Simon

Date: 23 Dec, 2010 01:21:04

Message: 4 of 10

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

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

From: Krishna Prasad Satamraju

Date: 23 Dec, 2010 06:32:05

Message: 5 of 10

"Sean de " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <ietgro$ddj$1@fred.mathworks.com>...
> "Krishna Prasad Satamraju" wrote in message <ietg1j$jf5$1@fred.mathworks.com>...
> > 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.
>
> doc reshape
>
> but why not just use blkproc to do the whole thing for you?
> doc blkproc
>
> or even cell2mat->cellfun->mat2cell
> 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

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

From: ramya s

Date: 18 Jan, 2011 15:30:09

Message: 6 of 10

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
> 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

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

From: eric paulraj

Date: 3 Mar, 2011 09:21:03

Message: 7 of 10

"Krishna Prasad Satamraju" wrote in message <ietg1j$jf5$1@fred.mathworks.com>...
> 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.


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

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

From: eric paulraj

Date: 3 Mar, 2011 09:22:08

Message: 8 of 10

"Krishna Prasad Satamraju" wrote in message <ietg1j$jf5$1@fred.mathworks.com>...
> 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.


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

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

From: Muhammad Imran

M@lik Ali

(Muhammad Imran)

Date: 1 Jul, 2012 08:55:06

Message: 9 of 10

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <e249575d-0b6e-462e-9a6b-ea9d090168e1@g26g2000vbi.googlegroups.com>...
> 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???

Can any one tel that how we can use this code for Color images.

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

From: Rashid Jamal

Date: 6 Jan, 2015 04:49:06

Message: 10 of 10

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.rashid@gmail.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us