How to apply dwt2 command as a function in blocproc?
Afficher commentaires plus anciens
I want to apply discrete wavelet transforms by dividing my image into different blocks. So, i am using blocproc command for it. When i am using, it is showing error as mention below. Please fix my problem.
Code i used,
clc; close all;
grayImage = imread('cameraman.tif'); [rows,columns] = size(grayImage); % Display the original image. subplot(2, 1, 1); imshow(grayImage, []); caption = sprintf('Original Image\n%d by %d pixels', ... rows, columns); title(caption, 'FontSize', fontSize); % Enlarge figure to full screen. set(gcf, 'Position', get(0,'Screensize')); set(gcf, 'name','Image Analysis Demo', 'numbertitle','off')
% Each 3x3 block will get replaced by one value. % Block process the image. windowSize = 32;
% Output image will be smaller by a factor of windowSize. segproc = @wavelet; % segproc = @dwt2; blockyImage = blockproc(grayImage,[windowSize windowSize],segproc); [rowsP,columnsP,numberOfColorChannelsP] = size(blockyImage); subplot(2,1,2); imshow(blockyImage, []); caption = sprintf('Image Processed in %d by %d Blocks\n%d by %d pixels\nCustom Box Filter', ... windowSize, windowSize, rowsP, columnsP); title(caption, 'FontSize', fontSize);
------------------------------------------------------------------------------------------------------------------- function [res]=wavelet(x) % Calculating Discrete wavelet transform. [cA,cH,cV,cD] = dwt2(x1,'sym4','mode','per') res=cA; ------------------------------------------------------------------------------------------------------------------- When i am using that code, i am getting the following error.
Function BLOCKPROC encountered an error while evaluating the user supplied function handle, FUN.
The cause of the error was:
Error using double Conversion to double from struct is not possible.
Error in dwt2 (line 84) x = double(x);
Error in wavelet (line 9) [cA,cH,cV,cD] = dwt2(x,'sym4','mode','per');
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Image Analysis dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!