need help with accessing every block of image for calculating svd of these blocks
Show older comments
Hi everyone, i have done coding for my project related to image forensics. But now i am stuck at finding svd of each block of the image. Here is my code snippet.
clc;
clear;
close all;
%%read image
im = [];
[FileName,PathName] = uigetfile({'*.png';'*.jpeg';'*.bmp';'*.gif';'*.jpg'},'Select the Image file');
if~(isequal(FileName,0)|| isequal(PathName,0))
m= fullfile(PathName,FileName);
im = imread(m);
end
img = im2double(rgb2gray(im));
[f1, f2] = size(img);
%%1- Apply Stationary wavelet transform up to specified level "L" to the gray image.
disp('1-Applying SWT to grayscale image ');
disp('1-Wavelet.....');
LL{1} = img;
k = 1;
[LL{k}, LH{k}, HL{k}, HH{k}] = swt2(LL{k},1,'db6');
%%2- Divide the image into overlapping blocks.
disp('2- Dividing the image into overlapping blocks of size 16x16');
block_size = 16;
patches = im2col(LL{1}(:,:,1),[block_size,block_size],'sliding'); %breaks image into blocks
[m1, n1] = size(patches);
num_blocks = (1:n1);
%%3- Apply SVD to each block
disp('3- Feature extraction by computing the SVD Transform of each 16x16 window');
so i am no getting how to access each block and apply SVD to each block. Plz help me if anybody knows regarding this.
10 Comments
TUSHAR MURATKAR
on 16 Sep 2017
Walter Roberson
on 17 Sep 2017
We do not understand why you did not use blockproc()
TUSHAR MURATKAR
on 17 Sep 2017
Jan
on 17 Sep 2017
@TUSHAR MURATKAR: because it would solve the problem.
TUSHAR MURATKAR
on 17 Sep 2017
Jan
on 17 Sep 2017
@TUSHAR MURATKAR: Please start with reading the documentation: https://www.mathworks.com/help/images/ref/blockproc.html. Then try it by your own and ask a specific question in the case of problems. I assume you want something like this:
B = blockproc(img, [16, 16], @svd)
TUSHAR MURATKAR
on 17 Sep 2017
Image Analyst
on 17 Sep 2017
You should use blockproc() like everyone is saying. I attach some demos that you can adapt as needed.
TUSHAR MURATKAR
on 17 Sep 2017
TUSHAR MURATKAR
on 17 Sep 2017
Accepted Answer
More Answers (0)
Categories
Find more on Neighborhood and Block Processing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!