how to divide a color image into blocks?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
yashi gautam
am 16 Nov. 2015
Kommentiert: Walter Roberson
am 25 Aug. 2017
sir, my project is watermarking into a colored image(divided into 128x128 dimension 4 blocks) using dwt and svd technique.
I have written the following code for the full color image dwt and svd.
clc
close all
%original image
org_img=imread('lena.jpg');
figure;
imshow(org_img);
title('Original color image');
[h_LL,h_LH,h_HL,h_HH]=dwt2(org_img,'haar');
img=h_LL;
red1=img(:,:,1);
green1=img(:,:,2);
blue1=img(:,:,3);
[U_imgr1,S_imgr1,V_imgr1]= svd(red1);
[U_imgg1,S_imgg1,V_imgg1]= svd(green1);
[U_imgb1,S_imgb1,V_imgb1]= svd(blue1);
%watermark imagee
org_img=imread('fruits.jpg');
figure;
imshow(org_img);
title('Watermark image');
[w_LL,w_LH,w_HL,w_HH]=dwt2(org_img,'haar');
img_wat=w_LL;
red2=img_wat(:,:,1);
green2=img_wat(:,:,2);
blue2=img_wat(:,:,3);
[U_imgr2,S_imgr2,V_imgr2]= svd(red2);
[U_imgg2,S_imgg2,V_imgg2]= svd(green2);
[U_imgb2,S_imgb2,V_imgb2]= svd(blue2);
% watermarking by SVD
S_wimgr=S_imgr1+(0.10*S_imgr2);
S_wimgg=S_imgg1+(0.10*S_imgg2);
S_wimgb=S_imgb1+(0.10*S_imgb2);
wimgr = U_imgr1*S_wimgr*V_imgr1';
wimgg = U_imgg1*S_wimgg*V_imgg1';
wimgb = U_imgb1*S_wimgb*V_imgb1';
wimg=cat(3,wimgr,wimgg,wimgb);
newimage_LL=wimg;
%output
rgb2=idwt2(newimage_LL,h_LH,h_HL,h_HH,'haar');
imwrite(uint8(rgb2),'Watermarked.jpg');
figure;imshow(uint8(rgb2));title('Watermarked Image');
kindly tell me how to divide this host image 'lena.jpg' into 4 blocks of size 128x128 using either a looping technique or mat2cell. also dierct me if i can use functions to access differnt blocks of the image.
regards
Yashi
2 Kommentare
TUSHAR MURATKAR
am 25 Aug. 2017
i have one question. after running this code i got cellarray of size 2x2. This i understood . but each cell is of size 192x56 . why it is like this why not 128x128 ? any help will be appreciated.
Walter Roberson
am 25 Aug. 2017
The above code does not create cell arrays. The code I posted does.
What does size(org_img) show for you?
Akzeptierte Antwort
Walter Roberson
am 16 Nov. 2015
img4x4 = mat2cell( org_img, size(orig_img,1)/2 * ones(1,2), size(orig_img,2)/2 * ones(1,2), size(orig_img,3) );
3 Kommentare
Walter Roberson
am 16 Nov. 2015
img4x4{1,1} %upper left
img4x4{1,2} %upper right
img4x4{2,1} %lower left
img4x4{2,2} %lower right
I should have called it img2x2 intead of img4x4 though ;-)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!