How to extract the highest 300 coefficient from each level of decomposition in shearlet transform( from level 1 to 5).

2 views (last 30 days)
I have extracted some statistical features (mean, standard deviation, constranst.. etc), but Now I want to test using highest 300 coefficients from each level of decompostion... please I need your suggestion. Thank you
if nargin < 1
img = double(imread('Img205.png','png'));
end
[row col] = size(img);
ndir = [2 2 1 1 0];
for j = 1:5
for k = -2^(ndir(j)):2^(ndir(j))
coeff_h{j}(:,:,k+(2^(ndir(j))+1)) = obtain_shear_coeff(img,[3 3 4 4 5],ndir(j),'hor',j,k);
coeff_v{j}(:,:,k+(2^(ndir(j))+1)) = obtain_shear_coeff(img,[3 3 4 4 5],ndir(j),'ver',j,k);
end
end
% Display original image
colormap gray;
subplot(1,1,1), imagesc( img, [0 255] ) ;
title( sprintf('Original Image' )) ;
% Display shearlet coeff for horizontal cone
figure; clf;
colormap gray;
tmp1 = []; tmp2 = []; tmp3 = []; tmp4 = []; tmp5 = [];
for k = 1:9
if k < 9
tmp1 = [ tmp1; coeff_h{1}(:,:,k); 255*ones(5,col/2) ];
else
tmp1 = [ tmp1; coeff_h{1}(:,:,k)];
end
end
for k = 1:9
if k < 9
tmp2 = [ tmp2; coeff_h{2}(:,:,k); 255*ones(5,col/4) ];
else
tmp2 = [ tmp2; coeff_h{2}(:,:,k)];
end
end
for k = 1:5
if k < 5
tmp3 = [ tmp3; coeff_h{3}(:,:,k); 255*ones(5,col/8) ];
else
tmp3 = [ tmp3; coeff_h{3}(:,:,k)];
end
end
for k = 1:5
if k < 5
tmp4 = [ tmp4; coeff_h{4}(:,:,k); 255*ones(5,col/16) ];
else
tmp4 = [ tmp4; coeff_h{4}(:,:,k)];
end
end
for k = 1:3
if k < 3
tmp5 = [ tmp5; coeff_h{5}(:,:,k); 255*ones(5,col/32) ];
else
tmp5 = [ tmp5; coeff_h{5}(:,:,k)];
end
end
subplot(1,5,1), imagesc( tmp1 ) ;
subplot(1,5,2), imagesc( tmp2 ) ;
subplot(1,5,3), imagesc( tmp3 ) ;
title( sprintf('Shearlet Coefficients for horizontal cone' )) ;
subplot(1,5,4), imagesc( tmp4 ) ;
subplot(1,5,5), imagesc( tmp5 ) ;
% Display shearlet coeff for vertical cone
figure; clf;
colormap gray;
tmp1 = []; tmp2 = []; tmp3 = []; tmp4 = []; tmp5 = [];
for k = 1:9
if k < 9
tmp1 = [ tmp1 coeff_v{1}(:,:,k) 255*ones(row/2,5) ];
else
tmp1 = [ tmp1 coeff_v{1}(:,:,k)];
end
end
for k = 1:9
if k < 9
tmp2 = [ tmp2 coeff_v{2}(:,:,k) 255*ones(row/4,5) ];
else
tmp2 = [ tmp2 coeff_v{2}(:,:,k)];
end
end
for k = 1:5
if k < 5
tmp3 = [ tmp3 coeff_v{3}(:,:,k) 255*ones(row/8,5) ];
else
tmp3 = [ tmp3 coeff_v{3}(:,:,k)];
end
end
for k = 1:5
if k < 5
tmp4 = [ tmp4 coeff_v{4}(:,:,k) 255*ones(row/16,5) ];
else
tmp4 = [ tmp4 coeff_v{4}(:,:,k)];
end
end
for k = 1:3
if k < 3
tmp5 = [ tmp5 coeff_v{5}(:,:,k) 255*ones(row/32,5) ];
else
tmp5 = [ tmp5 coeff_v{5}(:,:,k)];
end
end
subplot(5,1,1), imagesc( tmp1 ) ;
title( sprintf('Shearlet Coefficients for vertical cone' )) ;
subplot(5,1,2), imagesc( tmp2 ) ;
subplot(5,1,3), imagesc( tmp3 ) ;
subplot(5,1,4), imagesc( tmp4 ) ;
subplot(5,1,5), imagesc( tmp5 ) ;
%
% Copyright (c) 2010. Wang-Q Lim
  2 Comments
shakin banu
shakin banu on 4 Jan 2018
Sir, While executing this code , I am getting error as Undefined function 'obtain_shear_coeff' for input arguments of type 'double'.
Error in sheacoef (line 8) coeff_h{j}(:,:,k+(2^(ndir(j))+1)) = obtain_shear_coeff(img,[3 3 4 4 5],ndir(j),'hor',j,k); Kindly help me to run this code. Also I would like to know how to extract sparse coefficients from shearlet transform.
by Shakin, Ph.D Research Scholar

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 17 Aug 2015
[sorted_data, sort_index] = sort(DataYouWantToGetTop300ValuesOf);
top300values = sorted_data(end-299:end);
index_of_top300values = sort_index(end-299:end);

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!