How To Generate stack of 2D images with Interface [+]
Generate stack of 2D images with Interface [+] [MatLab]
close all; clear all; clc;%User Welcomingh1 = 'Hi, TBL Member!';p1 = 'Choose your input images folder';choice1 = questdlg({h1 p1},'TBL_Wrinkle','Sure','Cancel','Sure');switch choice1case 'Sure'disp([choice1 ' coming right up.'])inputFolderDir = uigetdir;charAdd = '\';sourceDir = strcat(inputFolderDir,charAdd);imgInfo = PrepareInfo(sourceDir);imgNumber = imgInfo.N;imgWidth = imgInfo.W;numPixels = zeros(imgNumber);case 'Cancel'returnendp2 = 'Now choose your output images folder';choice2 = questdlg(p2,'TBL_Wrinkle','Sure','Cancel','Sure');switch choice2case 'Sure'disp([choice2 ' coming right up.'])outputFolderDir = uigetdir;outputDir = strcat(outputFolderDir,charAdd);case 'Cancel'returnendh3 = waitbar(0,'Please wait...');numPixels = 0;%Useful Codefor i = 0:imgNumber-1if i < 10fileInputName = [sourceDir num2str(i,'000%d') '.jpg'];baseFileName = sprintf('000%d.jpg', i);endif i >= 10 && i < 100fileInputName = [sourceDir num2str(i,'00%d') '.jpg'];baseFileName = sprintf('00%d.jpg', i);endif i >= 100 && i < 1000fileInputName = [sourceDir num2str(i,'0%d') '.jpg'];baseFileName = sprintf('0%d.jpg', i);endimg = imread(fileInputName);imgMed = filtering(img);img = img(1:end-1,:);imgSegmented = segmentation(imgMed);% Thin segmentationimgSegmentedThin = segmentationThin(imgSegmented);%Polyfit lineimgPolyfit = polyfitting(imgSegmented,imgWidth);imgMerged = imgPolyfit + imgSegmented;%Filling wrinkleimgWrinkle = wrinkleDetect(imgMerged,imgPolyfit);numPixels = numPixels + nnz(imgWrinkle);%Displaying Resultr1 = img;g1 = r1;b1 = r1;r1(imgWrinkle > 0) = 255;g1(imgSegmentedThin > 0) = 255;b1(imgWrinkle > 0) = 0;outputImage = cat(3,r1,g1,b1);%fullFileName = fullfile(Resultados, baseFileName); % No need to worry about slashes now!%imwrite(upd, fullFileName);fullFileName = [outputDir baseFileName];%imwrite(upd, baseFileName);imwrite(outputImage,fullFileName);%imshow(cat(3,r1,g1,b1),[]);%title(['Wrinkle Area with ' num2str(numPixels) 'pixels']);% Report current estimate in the waitbar's message fieldformatStep = 'Analyzing image %d';currentIteration = i+1;waitbar(currentIteration/imgNumber,h3,sprintf(formatStep,i))endclose(h3)%totalNumberPixels = sum(numPixels);h4 = msgbox(sprintf('Done! Total number of wrinkle pixels: %d',numPixels));