Reading the arranged file name
Afficher commentaires plus anciens
Hey need some assitance here,
I have 150 Images with the name of 1 until 150.
My code read the image as 1 10 100 101 etc instead of 1 2 3
So, instead of renaming my images 001 002 003 etc.
How to create a code to read and process my images in order of 1 2 3 4.... n
image_folder = 'F:\Microfluidic_Experments_Back_Up_May_2020\GEA\2020-09-02_Gea_aqeous_phase_10cP_Oil\2020-09-02_10-57-35'; % Enter name of folder from which you want to upload pictures with full path
filenames = dir(fullfile(image_folder, '*.jpg')); % read all images with specified extention, its jpg in our case
total_images = numel(filenames); % count total number of photos present in that folder
for n = 1:total_images
f= fullfile(image_folder, filenames(n).name); % it will specify images names with full path and extension
our_images = imread(f); % Read images
figure (n) % used tat index n so old figures are not over written by new new figures
%J = imrotate(our_images,90,'bilinear','loose');
%p=ginput(2)
K=imcrop(our_images,[1343 8 5581 5496]);
%imshow(K);
red=K(:,:,1);
green=K(:,:,2);
blue=K(:,:,3);
%d=impixel(K); %Manually Show Pixel Value
% Get the Water mask
OilMask = red > 180 & green > 170 ;
% Get the Bubble mask
PolyMask = red > 210 & green > 215 & blue > 170;
% Make Water mask green
red(OilMask) = 0;
green(OilMask) = 255;
blue(OilMask) = 0;
% Make the Bubble mask blue
red(PolyMask) = 0;
green(PolyMask) = 0;
blue(PolyMask) = 255;
% Recombine separate color channels into a single, true color RGB image.
rgbImage2 = cat(3, red, green, blue);
%subplot(2, 1, 2);
%Water Pixel Sum
OilPixels = rgbImage2(:,:,1) == 0 & rgbImage2(:,:,2) == 255 & rgbImage2(:,:,3) == 0;
numOilPixels(n) = sum(OilPixels(:));
%Bubble Pixel Sum
PolyPixels = rgbImage2(:,:,1) == 0 & rgbImage2(:,:,2) == 0 & rgbImage2(:,:,3) == 255;
numPolyPixels(n) = sum(PolyPixels(:));
imshow(rgbImage2);
% numOil(n) = numel(OilPixels);
% numPoly(n) = numel(PolyPixels);
%SAVING FIGURE
path='F:\Microfluidic_Experments_Back_Up_May_2020\GEA\2020-09-02_Gea_aqeous_phase_10cP_Oil_MATLAB_RESULT\Binary Image';
saveas(figure(n),fullfile(path,['Figure' num2str(n) '.jpeg']));
%imshow(our_images) % Show all images
close
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Scripts 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!