Error in extracting wavelet based features from images
2 views (last 30 days)
Show older comments
Warid Islam on 22 Jul 2021
Answered: Prabhan Purwar on 28 Jul 2021
I am trying to extract wavelet based features from images. The wavelet decomposition is accomplished
on the original ROI. The output lowpass sub-band of the wavelet transform is further decompressed into
two more sequences. This three-level of decompositions is done to filter out redundant information and obtain the image
compressed enough. Then, putting together the last four sub-bands are used to build a matrix of four sub-bands. To further
compress them, principal components of this matrix are driven for feature extraction. My code works fine for a single image. But when I try to
extract the features of all the images in the folder, Matlab throws me an error message. Any suggestions would be helpful.
myFolder = 'D:\regionGrowing_MLT\newim\Segmentation Results';
% Check to make sure that folder actually exists. Warn user if it doesn't.
errorMessage = sprintf('Error: The following folder does not exist:\n%s\nPlease specify a new folder.', myFolder);
myFolder = uigetdir(); % Ask for a new one.
if myFolder == 0
% User clicked Cancel
% Get a list of all files in the folder with the desired file name pattern.
filePattern = fullfile(myFolder, '*.jpg'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for k = 1 : length(theFiles)
baseFileName = theFiles(k).name;
fullFileName = fullfile(theFiles(k).folder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
% Now do whatever you want with this file name,
% such as reading it in as an image array with imread()
imageArray = imread(fullFileName);
% I=imread('segFP1.jpg');% intensity image
[HH,HL,LL,LH] = dwt2(imageArray,'sym4','mode','per');
[HH1,HL1,LL1,LH1] = dwt2(LL,'sym4','mode','per');
[HH2,HL2,LL2,LH2] = dwt2(LL1,'sym4','mode','per');
glcms = graycomatrix(p);
stats = graycoprops(glcms,'Contrast Correlation Energy Homogeneity');
Contrast = stats.Contrast;
Correlation = stats.Correlation;
Energy = stats.Energy;
Homogeneity = stats.Homogeneity;
Mean = mean2(p);
Standard_Deviation = std2(p);
Entropy = entropy(p);
RMS = mean2(rms(p));
Skewness = skewness(double(p(:)));
Kurtosis = kurtosis(double(p(:)));
Variance = mean2(var(double(p)));
a = sum(double(p(:)));
Smoothness = 1-(1/(1+a));
% Inverse Difference Movement
m = size(i,1);
n = size(i,2);
in_diff = 0;
for i = 1:m
for j = 1:n
temp = p(i,j)./(1+(i-j).^2);
in_diff = in_diff+temp;
IDM = double(in_diff);
ff(k,:) = [Contrast, Correlation, Energy,Homogeneity, Mean, Standard_Deviation, Entropy, RMS, Skewness, Kurtosis, Variance, Smoothness, IDM];
The following error message is being displayed:
Error using bsxfun
Non-singleton dimensions of the two input arrays must match each other.
Error in pca>localSVD (line 481)
x = bsxfun(@times, x, PhiSqrt);
Error in pca (line 354)
[U,sigma, coeff, wasNaN] = localSVD(x, n,...
Error in win (line 26)
Prabhan Purwar on 28 Jul 2021
I tried to replicate the issue in R2021a but the code seems to work without any error with all the three images. Could you elaborate upon the reproduction steps so that we can replicate the issue.
Find more on Continuous Wavelet Transforms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!