looking for imaging processing expert

1 visualización (últimos 30 días)
Abdussalam Elhanashi
Abdussalam Elhanashi el 22 de Oct. de 2020
Comentada: Walter Roberson el 23 de Oct. de 2020
Hi
I have a problem with using autoencoder for recreating fingerprinting images
I am using MATLAB and Sparse autoencoder
I am using extractHOGFeatures for extracting the features to be trained for autoencoder
I got good results on the performance of training and mseError which reaching 0.0039 However when i use autoencoder with testing images i got black color on the whole Reconstructed images
I followed this example in MATLAB for autoencoder but I am still facing the problem for Reconstructed images that are with black color for whole images
Herein the code
% Data processing
clear all;
close all;
clc;
%% Initalize the data
dataDir= fullfile('Data/');
exts = {'.jpg','.png','.tif','BMP'};
imds = imageDatastore(fullfile(dataDir),...
'IncludeSubfolders',true,'FileExtensions','.jpg','LabelSource','foldernames');
countEachLabel(imds);
[TrainData, TestData] = splitEachLabel(imds, 0.5);
size(TrainData);
countEachLabel(TrainData);
%% reference
figure();
imshow(TrainData.Files{1});
img = readimage(TrainData, 1);
[hog_8x8, vis8x8] = extractHOGFeatures(img, 'CellSize', [8 8]);
CellSize = [8 8];
hogFeatureSize = length (hog_8x8);
numImages = numel(TrainData.Files);
trainingFeatures = zeros(numImages, hogFeatureSize, 'single');
for i = 1:numImages
img = readimage(TrainData, i);
img = imbinarize(img);
trainingFeatures(i, :) = extractHOGFeatures(img, 'CellSize', CellSize);
end
%% Training Data
trainingLabels = TrainData.Labels;
X = trainingFeatures;
%% train a spare autoencoder
hiddenSize = 25;
autoenc = trainAutoencoder(X,hiddenSize,'MaxEpochs',1000,...
'DecoderTransferFunction','purelin','EncoderTransferFunction','satlin','L2WeightRegularization',0.004,'SparsityRegularization',4,'SparsityProportion',0.15);
Xreconstructed = predict(autoenc, X);
mseError = mse(X - Xreconstructed);
figure();
for i = 1:10
subplot(4,5,i);
imshow(Xreconstructed(i));
end
%% Test data
img = readimage(TestData, 1);
[hog_8x8, vis8x8] = extractHOGFeatures(img, 'CellSize', [8 8]);
CellSize = [8 8];
hogFeatureSize = length (hog_8x8);
numImages = numel(TestData.Files);
testingFeatures = zeros(numImages, hogFeatureSize, 'single');
for i = 1:numImages
img = readimage(TestData, i);
img = imbinarize(img);
testingFeatures(i, :) = extractHOGFeatures(img, 'CellSize', CellSize);
end
testingLabels = TestData.Labels;
testFeature = reshape(testingFeatures, [102 20736]);
testFeature'; %#ok<VUNUS>
xReconstructed = predict(autoenc,testFeature);
%% Test Images
figure();
for i = 1:10
subplot(4,5,i);
imshow(TestData.Files{i});
end
%% Reconstructed images from TestData
figure();
for i = 1:10
subplot(4,5,i);
imshow(xReconstructed(i));
end

Respuestas (1)

Walter Roberson
Walter Roberson el 23 de Oct. de 2020
imshow(Xreconstructed(i));
What datatype is Xreconstructed(i) ? It looks to me from the code that it will be scalar double, in the range of 1 to the number of classes or perhaps 0 to 255. It looks to me as if you are asking imshow() to display one pixel at a time, and without scaling it either.
You should probably be using something more like
imshow(Xreconstructed, [0 255])
  4 comentarios
Abdussalam Elhanashi
Abdussalam Elhanashi el 23 de Oct. de 2020
Hi Walter
Thank you for your reply
I used imshow(xreconstructed, []) but i get following result one line with dots
supposed to be as these or similar to fingerprints
Walter Roberson
Walter Roberson el 23 de Oct. de 2020
No it should not be anything like that when you display that array. You are extracting HOG features from the image, building an autoencoder, and putting the extracted features through the autoencoder prediction. The result is the same size as the extracted features, not the same size as the image, so you should not expect that the visualization of it would resemble a fingerprint in any respect.

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by