How to read & display multiple images from a folder
Mostrar comentarios más antiguos
I have 20 TIFF images in MATLAB directory. How can I read them all & show them in different windows i.e. 20 windows for 20 images? I am new to MATLAB & currently using MATLAB & Simulink Release 2009a. After reading the images, how to display them one by one on screen?
16 comentarios
anuja
el 5 de Feb. de 2014
If I have dicom image sequences stored in a folder, this method does not help. How do I read all the files sequentially from a folder?
Image Analyst
el 5 de Feb. de 2014
See the FAQ link given by Walter below.
Soumya Elsa Babu
el 17 de Feb. de 2017
where to view the output? i am working with matlab 2013..
Walter Roberson
el 17 de Feb. de 2017
Well for example with the code
srcFiles = dir('E:\New Folder\IM_*.dcm');
for i = 1 : length(srcfiles)
filename = strcat('E:\New Folder\',srcFiles(i).name);
I = dicomread(filename);
figure, imshow(I);
end
then each image is put into its own figure, and could be viewed there.
Nav Desh
el 20 de Jun. de 2017
thanks a lot. nice work..
arshpreet kaur
el 11 de Oct. de 2017
Editada: DGM
el 12 de Feb. de 2023
myfile=dir('C:\Users\Documents\*.jpg'); % the folder inwhich ur images exists
for i = 1 : length(myfile)
filename = strcat('C:\Users\Documents\',myfile(i).name); k=importdata(filename);
end
pawarcse
el 27 de Dic. de 2017
And what if we want all images(198) in one window? How to apply subplot using for loop?
Image Analyst
el 27 de Dic. de 2017
Try this:
numFiles = length(myfile);
numRows = ceil(sqrt(numFiles));
for k = 1 : numFiles
thisFileName = fullfile(myfile(k).folder, myfile(k).name);
thisImage = imread(thisFileName);
subplot(numRows, numRows, k);
imshow(thisImage);
end
pawarcse
el 28 de Dic. de 2017
Thank you very much sir!!
Sakthimurugan Ravi
el 4 de Ag. de 2018
not working
Image Analyst
el 4 de Ag. de 2018
Not true. It DOES work. I just tried it again. Here is my code:
myfile=dir('*.jpg'); % the folder inwhich ur images exists
numFiles = length(myfile)
numRows = ceil(sqrt(numFiles))
for k = 1 : numFiles
thisFileName = fullfile(myfile(k).folder, myfile(k).name);
thisImage = imread(thisFileName);
subplot(numRows, numRows, k);
imshow(thisImage);
title(myfile(k).name, 'Interpreter', 'none');
drawnow;
end
Perhaps myfile is empty for you, meaning no files in the folder. You should check for that.
Shel
el 24 de Ag. de 2018
I have series of 1600 dicom images with the name 6--12-1.dcm, 6--12-2.dcm, 6--12-3.dcm and so on. how can I read the sequence and do the filtering on images and save them in another folder? here is my code but it gives me errors, can you please help me to correct it:
source_dir=uigetdir([]); %I= dir('C:\Users\Shan\Desktop\CT Images')
pwd
d=dir([source_dir,'\6--12-*.dcm']);
totalfile=length(d);
resultfolder='C:\Users\Shan\Desktop\CT Images\Median'
for i=1:totalfile
fname=['6--12-',num2str(i), '.dcm'];
indicom=dicomread(fullfile(source_dir, fname));
subplot(1,2,1), imshow(indicom,[]);
title(sprintf('original image number %d',i));
medianfilter{i}=medfilt2(indicom{i},[4 4]);
BasedFileName=sprint('%d.dcm',i);
FilteredFileName=fullfile(resultfolder,BasedFileName)
dicomwrite(medianfilter, FilteredFileName);
subplot(1,2,2), imshow(medianfilter,[]);
title(sprintf('median filtered image number %d',i));
end
Actually, I have asked it in several places but I could not find the answer, I would appreciate it if you could help me to solve this problem pleasee!
Image Analyst
el 24 de Ag. de 2018
You forgot to post the errors. It looks like you're storing the median filtered image in one cell of a cell array but you're not extracting that image from the cell when you want to display it with imshow() or write a new copy of it with dicomwrite(). And you're treating indicom as a cell array when it's just a regular image. Try using indicom and medianfilter{i}:
imshow(indicom,[]);
dicomwrite(medianfilter{i}, FilteredFileName);
subplot(1,2,2), imshow(medianfilter{i},[]);
Then look at the FAQ: https://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F to know when you should use round parentheses, square brackets, or curly braces, or none of those.
Bachtiar Muhammad Lubis
el 29 de En. de 2019
Editada: DGM
el 12 de Feb. de 2023
@image analyst: i actually had implemented
my_folder ='D:\testing';
filenames=dir(fullfile(my_folder,'*.bmp');
for n = 1:numel(filenames)
fullname=fullfile(my_folder,filenames(n).name);
template = imread(fullname);
letters = [letters, template];
end
characters = (letters);
when i compared images of characters content sequence with my source images. the sequence isn't same. why did it happen sir , and how to makes characters content has same saquence with my sources images ?
shobhana
el 3 de Feb. de 2023
hi can you help me regarding MATLAB in test image i wanna run multiple images folders so how i can run group of images in the matlab
Image Analyst
el 3 de Feb. de 2023
@shobhana try this:
% Process a sequence of files.
filePattern = fullfile(pwd, '*.png');
imds = imageDatastore(filePattern) % Create an image Datastore
% Get all filenames into one cell array. Filenames have the complete path (folder prepended).
allFileNames = imds.Files;
numFiles = numel(imds.Files);
for k = 1 : numel(allFileNames)
% Get this file name.
fullFileName = allFileNames{k};
fprintf('Processing %s\n', fullFileName);
% Now do something with fullFileName, such as passing it to imread.
end
If that does not work for you then try starting your own question so we can figure it out.
Respuesta aceptada
Más respuestas (5)
Delowar Hossain
el 19 de Oct. de 2015
Editada: Walter Roberson
el 19 de Oct. de 2015
jpgFiles = dir('*.jpg');
numFiles = length(jpgFiles);
mydata = cell(1,numFiles);
% mydata = zeros(numFiles);
for k = 1:numFiles
mydata{k} = imread(jpgFiles(k).name);
end
for k = 1:numFiles
% subplot(4,5,k);
figure;
imshow(mydata{k});
end
9 comentarios
niousha hormozi
el 5 de Nov. de 2015
I used your code and it doesnt work! there is an error in "mydata{k} = imread(jpgFiles(k).name);" for imread!
Image Analyst
el 5 de Nov. de 2015
There was no error for me. Please post the complete code and complete error - ALL the red text.
Nav Desh
el 18 de Jul. de 2017
i have executed the same code. but it does not display the images in sequence. It shows the images as- image1,image10,image100 like that. i have 198 images in my folder. please tell me how to change the sequence of images to display.
Image Analyst
el 18 de Jul. de 2017
Nav, like I said above, your problem will be solved if you look at these links:
Did you even try Stephen's code?
Nav Desh
el 20 de Jul. de 2017
got the results. Thank you.
Bharath AS
el 1 de Mzo. de 2019
thank u
Diana Tsvetkova
el 14 de Mzo. de 2022
i want to thank too !! This helped me a lot
Noor Fatima
el 4 de Abr. de 2022
I want to make a sub-plot with all the images in directory, although ypu have commented subplot line but I'm not getting the point . May I please request you that how can I plot all those image in to one plot?
Image Analyst
el 4 de Abr. de 2022
@Noor Fatima, try montage() or imtile().
Image Analyst
el 24 de Dic. de 2012
1 voto
You might want to consider the montage() function in the Image Processing Toolbox.
Otherwise you can use set(handle, 'Position'...) to arrange your figures on screen.
There is also a way to "dock" figures as tabbed windows in a single figure that you can size to take up the whole screen, though I forget what the code is to dock multiple figures into one. I'm sure Jan or someone else knows though.
11 comentarios
ayushi
el 23 de Jun. de 2016
but sir if i want to fed all the images to a function and want that function will execute for each and every image then what should i have to do??
Image Analyst
el 26 de Jun. de 2016
Write your function, then call it while passing your "images" (or image filenames) to it. Do you not know how to write a function? If not, it's explained in the help, probably in the "Getting Started" section.
no no sir i know how to create functions but suppose i have a function for image show:
function_show(parameters)
imshow('');
end
something like this but if i want to show all the images present in a folder by passing them to this function;so that all images can be show with using single function
Image Analyst
el 4 de Jul. de 2016
Either see the second code block in the FAQ http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F (scroll down to see it), or else use the montage() function, depending how what "show all the images" means to you.
sir suppose there is a folder and there are some images of .png format and i want to get the features of all those images one by one by feeding them to the code given below :
function [features]=feature_extractor_2d(image)
%this function zones the input image and extracts features for each zone.
% skeletonizing image
image=bwmorph(image,'skel',inf);
%selecting the universe of discourse
image=discourser(image);
original_image=image;% just backing up the orginal image
row=size(image,1);
column=size(image,2);
% we have to ceil this no.s to the nearest multiple of 3 since
% 3x3 windowing is used
% first we have to ensure that image consists of minimum 9 rows and minimum
% 9 columns
add_rows=0; %no of additional rows to make min of 9x9 matrix
add_columns=0; % similar for columns
if row<9
add_rows=9-row;
end
if column<9
add_columns=9-column;
end
if mod(add_rows,2)==0
image=[zeros(add_rows/2,column);image;zeros(add_rows/2,column)];
else
image=[zeros((add_rows-1)/2,column);image;zeros((add_rows+1)/2,column)];
end
%appending rows of zeros
%after above op, no.of rows changes so it should be updated
%equal no of rows should be added on top and bottom
row=size(image,1);
if mod(add_columns,2)==0
image=[zeros(row,(add_columns)/2),image,zeros(row,(add_columns)/2)];
else
image=[zeros(row,(add_columns-1)/2),image,zeros(row,(add_columns+1)/2)];
end
column=size(image,2); %updating the column value
n_rows=ceil(row/3)*3-row; % no of rows of zeros to be added
n_columns=ceil(column/3)*3-column; % no of columns of zeros to be added
% assume row=4, so 2 rows of zeros should be added. ceil(4/3)*3 will return
% 6 which is nearest multiple of 3 to 4 from right side. So n_rows will
% contain no.of rows to be added to the image.
if mod(n_rows,2)==0
image=[zeros(n_rows/2,column);image;zeros(n_rows/2,column)];
else
image=[zeros((n_rows-1)/2,column);image;zeros((n_rows+1)/2,column)];
end
%appending rows of zeros
%after above op, no.of rows changes so it should be updated
%equal no of rows should be added on top and bottom
row=size(image,1);
if mod(n_columns,2)==0
image=[zeros(row,(n_columns)/2),image,zeros(row,(n_columns)/2)];
else
image=[zeros(row,(n_columns-1)/2),image,zeros(row,(n_columns+1)/2)];
end
column=size(image,2); %updating the column value
% so now the image can be divided into 3x3 zones
% here in above code some more features are to be added, like if two rows
% of zeros are to be added then one on either side of the image and
% similarily for columns.
column_zone_height=row;
column_zone_width=column/3;
%say at this point image is 12x9, so no.of rows in each column zone should be
%12, whereas columns should be 9/3=3. This is stored in variables zone
%height and width
column_zone1=image(1:column_zone_height,1:column_zone_width);
column_zone2=image(1:column_zone_height,(column_zone_width+1):2*column_zone_width);
column_zone3=image(1:column_zone_height,(2*column_zone_width+1):end);
row_zone_height=row/3;
row_zone_width=column;
row_zone1=image(1:row_zone_height,1:row_zone_width);
row_zone2=image((row_zone_height+1):2*row_zone_height,1:row_zone_width);
row_zone3=image((2*row_zone_height+1):end,1:row_zone_width);
% feature_vectors
column_zone1_features=lineclassifier(column_zone1);
column_zone2_features=lineclassifier(column_zone2);
column_zone3_features=lineclassifier(column_zone3);
row_zone1_features=lineclassifier(row_zone1);
row_zone2_features=lineclassifier(row_zone2);
row_zone3_features=lineclassifier(row_zone3);
% this is a feature called euler no...euler no. is diff between no.of
% objects and holes in that image
euler=bweuler(image);
features=[column_zone1_features;column_zone2_features;column_zone3_features;row_zone1_features;row_zone2_features;row_zone3_features];
features=[reshape(features',numel(features),1);euler];
% here the region properties of the image are going to be considered
stats=regionprops(bwlabel(image),'all');
skel_size=numel(image);
%convexarea=(stats.ConvexArea)/skel_size;
eccentricity=stats.Eccentricity;
extent=stats.Extent;
%filledarea=(stats.FilledArea)/skel_size;
%majoraxislength=(stats.MajorAxisLength)/skel_size;
%minoraxislength=(stats.MinorAxisLength)/skel_size;
orientation =stats.Orientation;
% this are the regional features
regional_features=[eccentricity;extent;orientation];
i tried following procedure but its not working properly and not getting how to do this work:
srcFiles = dir('C:\Users\Omm\Downloads\multicharacterrec\*.png'); % the folder in which ur images exists
for i = 1 : length(srcFiles)
filename = strcat('C:\Users\Omm\Downloads\multicharacterrec\',srcFiles(i).name);
function()
%something something %
end
end
Image Analyst
el 4 de Jul. de 2016
Two problems. (1) Don't name your variable image since that's a built in function, and secondly, don't call function(), do it this way:
thisImage = imread(filename);
features = feature_extractor_2d(thisImage)
ayushi
el 4 de Jul. de 2016
it's showing following error sir :(
Function definitions are not permitted in this context.
code:
srcFiles = dir('C:\Users\Omm\Downloads\multicharacterrec\*.png'); % the folder in which ur images exists
for i = 1 : length(srcFiles)
filename = strcat('C:\Users\Omm\Downloads\multicharacterrec\',srcFiles(i).name);
thisImage = imread(filename);
function [features]=feature_extractor_2d(thisImage)
%this function zones the input image
% and extracts features for each zone.
% skeletonizing image
image=bwmorph(image,'skel',inf);
%selecting the universe of discourse
image=discourser(image);
original_image=image;% just backing up the orginal image
row=size(image,1);
column=size(image,2);
% we have to ceil this no.s to the nearest multiple of 3 since
% 3x3 windowing is used
% first we have to ensure that image consists of minimum 9 rows and minimum
% 9 columns
add_rows=0; %no of additional rows to make min of 9x9 matrix
add_columns=0; % similar for columns
if row<9
add_rows=9-row;
end
if column<9
add_columns=9-column;
end
if mod(add_rows,2)==0
image=[zeros(add_rows/2,column);image;zeros(add_rows/2,column)];
else
image=[zeros((add_rows-1)/2,column);image;zeros((add_rows+1)/2,column)];
end
%appending rows of zeros
%after above op, no.of rows changes so it should be updated
%equal no of rows should be added on top and bottom
row=size(image,1);
if mod(add_columns,2)==0
image=[zeros(row,(add_columns)/2),image,zeros(row,(add_columns)/2)];
else
image=[zeros(row,(add_columns-1)/2),image,zeros(row,(add_columns+1)/2)];
end
column=size(image,2); %updating the column value
n_rows=ceil(row/3)*3-row; % no of rows of zeros to be added
n_columns=ceil(column/3)*3-column; % no of columns of zeros to be added
% assume row=4, so 2 rows of zeros should be added. ceil(4/3)*3 will return
% 6 which is nearest multiple of 3 to 4 from right side. So n_rows will
% contain no.of rows to be added to the image.
if mod(n_rows,2)==0
image=[zeros(n_rows/2,column);image;zeros(n_rows/2,column)];
else
image=[zeros((n_rows-1)/2,column);image;zeros((n_rows+1)/2,column)];
end
%appending rows of zeros
%after above op, no.of rows changes so it should be updated
%equal no of rows should be added on top and bottom
row=size(image,1);
if mod(n_columns,2)==0
image=[zeros(row,(n_columns)/2),image,zeros(row,(n_columns)/2)];
else
image=[zeros(row,(n_columns-1)/2),image,zeros(row,(n_columns+1)/2)];
end
column=size(image,2); %updating the column value
% so now the image can be divided into 3x3 zones
% here in above code some more features are to be added, like if two rows
% of zeros are to be added then one on either side of the image and
% similarily for columns.
column_zone_height=row;
column_zone_width=column/3;
%say at this point image is 12x9, so no.of rows in each column zone should be
%12, whereas columns should be 9/3=3. This is stored in variables zone
%height and width
column_zone1=image(1:column_zone_height,1:column_zone_width);
column_zone2=image(1:column_zone_height,(column_zone_width+1):2*column_zone_width);
column_zone3=image(1:column_zone_height,(2*column_zone_width+1):end);
row_zone_height=row/3;
row_zone_width=column;
row_zone1=image(1:row_zone_height,1:row_zone_width);
row_zone2=image((row_zone_height+1):2*row_zone_height,1:row_zone_width);
row_zone3=image((2*row_zone_height+1):end,1:row_zone_width);
% feature_vectors
column_zone1_features=lineclassifier(column_zone1);
column_zone2_features=lineclassifier(column_zone2);
column_zone3_features=lineclassifier(column_zone3);
row_zone1_features=lineclassifier(row_zone1);
row_zone2_features=lineclassifier(row_zone2);
row_zone3_features=lineclassifier(row_zone3);
% this is a feature called euler no...euler no. is diff between no.of
% objects and holes in that image
euler=bweuler(image);
features=[column_zone1_features;column_zone2_features;column_zone3_features;row_zone1_features;row_zone2_features;row_zone3_features];
features=[reshape(features',numel(features),1);euler];
% here the region properties of the image are going to be considered
stats=regionprops(bwlabel(image),'all');
skel_size=numel(image);
%convexarea=(stats.ConvexArea)/skel_size;
eccentricity=stats.Eccentricity;
extent=stats.Extent;
%filledarea=(stats.FilledArea)/skel_size;
%majoraxislength=(stats.MajorAxisLength)/skel_size;
%minoraxislength=(stats.MinorAxisLength)/skel_size;
orientation =stats.Orientation;
% this are the regional features
regional_features=[eccentricity;extent;orientation];
end
Image Analyst
el 4 de Jul. de 2016
Look at the code I gave you. Why did you change from my code
features = feature_extractor_2d(thisImage)
to this, which broke it:
function [features]=feature_extractor_2d(thisImage)
WHY did you add the functions keyword at the beginning of the line????
I believe it will work if you do what I said. That said, features is not saved beyond that one iteration of the loop, so you'd better do something with it inside the loop.
ayushi
el 5 de Jul. de 2016
sir this is the function that i have taken for collecting the features
function [features]=feature_extractor_2d(thisImage)
to
% this are the regional features
regional_features=[eccentricity;extent;orientation];
Image Analyst
el 5 de Jul. de 2016
That does not make sense to me. Like I said, remove the word "function" when you actually call the function from your main routine. The word "function" should only be where you actually define/write the function, NOT where you call it from some other function.
ayushi
el 6 de Jul. de 2016
ok sir
murk hassan memon
el 11 de Feb. de 2018
Editada: Image Analyst
el 11 de Feb. de 2018
srcFiles = dir('E:\New Folder\IM_*.dcm');
for i = 1 : length(srcfiles)
filename = strcat('E:\New Folder\',srcFiles(i).name);
I = dicomread(filename);
figure, imshow(I);
end
i have tried this code but it is not displaying any output on screen just showing number of images and there names on workspace. kindly help me that how to read and display multiple images from folder
I have also tried this code
myfile=dir('C:\Users\Documents\*.jpg'); % the folder inwhich ur images exists
for i = 1 : length(myfile)
filename = strcat('C:\Users\Documents\',myfile(i).name);
k=importdata(filename);
end
but it displays all images on one screen so that the last image is displayed, but I want all these images on different window screen so what should I do?
Help me out please
4 comentarios
Image Analyst
el 11 de Feb. de 2018
Try this:
folder = 'C:\Users\Documents\';
filePattern = fullfile(folder, '*.jpg');
myFiles = dir(filePattern); % the folder inwhich ur images exists
rows = ceil(sqrt(length(myFiles)))
for k = 1 : length(myFiles)
fullFileName = fullfile(myFiles(k).folder, myFiles(k).name);
subplot(rows, rows, k);
imshow(fullFileName);
title(myFiles(k).name, 'Interpreter', 'none');
drawnow;
end
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
murk hassan memon
el 2 de Mzo. de 2018
yes i am getting my desired output. thanku very much
AP
el 9 de Jun. de 2020
Hello sir... i have tried this code but it is giving me error. Like Reference to non-existent field 'folder'.
Please guide me through this.
Walter Roberson
el 12 de Jun. de 2020
AP, you are probably using an old MATLAB release.
folder = 'C:\Users\Documents\';
filePattern = fullfile(folder, '*.jpg');
myFiles = dir(filePattern); % the folder inwhich ur images exists
rows = ceil(sqrt(length(myFiles)))
for k = 1 : length(myFiles)
fullFileName = fullfile(folder, myFiles(k).name);
subplot(rows, rows, k);
imshow(fullFileName);
title(myFiles(k).name, 'Interpreter', 'none');
drawnow;
end
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
Shel
el 4 de Feb. de 2019
Hello,
I have 1986 tif images and now I want to read the series but I do not know how I should do would you please guide me?
How can I read my series of images?
here is the name of my files and my code:
names:
T4-1-140-0001
T4-1-140-0002
...
T4-1-140-1986
code:
clc
clear all
image_folder='C:\Users\Shel\1';
source_dir=uigetdir([]);
d=dir([source_dir,'\T4-1-140-000*.tif']);
filename=dir(fullfile(image_folder, 'T4-1-140-*.tif'));
H='result.txt';
file1=fopen(H,'w');
total_image=numel(filename);
tic
for n=1:total_image
fname=['T4-1-140-000',num2str(i), '.tif'];
inimg=imread(fullfile(source_dir, fname))
%f=fullfile(image_folder,filename(n).name);
%indicom=imread(f);
image_totpx=numel(inimg);
miangin=mean(mean(inimg));
mmax = max(inimg(:));
mmin=min(min(inimg));
img_NB=length(inimg(inimg==255));
area=img_NB
P=area/image_totpx;
fprintf(file1,' %2.0f %10s %2.5f \r\n', i, ' ', p);
end
toc
fclose(file1);
Thank you very much
1 comentario
Image Analyst
el 4 de Feb. de 2019
Change this:
for n=1:total_image
fname=['T4-1-140-000',num2str(i), '.tif'];
to this
for n=1:total_image
fname=sprintf('T4-1-140-000%4.4d.tif', n);
You need to use n instead of i since n is the loop iterator, and use 4 digits for the number, which num2str() can't do, but sprintf() can.
sarah fteih
el 10 de Oct. de 2019
Editada: DGM
el 12 de Feb. de 2023
hi
i have done this code for k means algorithm segmenation as a part of image processing:
%% K-means Segmentation (option: K Number of Segments)
clc
clear all
close all
%% Load Image
I = im2double(imread('D:\PHD\Data\ADNI\Batch Output 2019-06-13-1234\ADNI_002_S_0295_MR_Axial_PD_T2_FSE__br_raw_20060418201146219_97_S13404_I13718.jpg')); % Load Image
F = reshape(I,size(I,1)*size(I,2),3); % Color Features
%% K-means
K = 4; % Cluster Numbers
CENTS = F( ceil(rand(K,1)*size(F,1)) ,:); % Cluster Centers
DAL = zeros(size(F,1),K+2); % Distances and Labels
KMI = 10; % K-means Iteration
for n = 1:KMI
for i = 1:size(F,1)
for j = 1:K
DAL(i,j) = norm(F(i,:) - CENTS(j,:));
end
[Distance, CN] = min(DAL(i,1:K)); % 1:K are Distance from Cluster Centers 1:K
DAL(i,K+1) = CN; % K+1 is Cluster Label
DAL(i,K+2) = Distance; % K+2 is Minimum Distance
end
for i = 1:K
A = (DAL(:,K+1) == i); % Cluster K Points
CENTS(i,:) = mean(F(A,:)); % New Cluster Centers
if sum(isnan(CENTS(:))) ~= 0 % If CENTS(i,:) Is Nan Then Replace It With Random Point
NC = find(isnan(CENTS(:,1)) == 1); % Find Nan Centers
for Ind = 1:size(NC,1)
CENTS(NC(Ind),:) = F(randi(size(F,1)),:);
end
end
end
end
X = zeros(size(F));
for i = 1:K
idx = find(DAL(:,K+1) == i);
X(idx,:) = repmat(CENTS(i,:),size(idx,1),1);
end
T = reshape(X,size(I,1),size(I,2),3);
%% Show
figure()
subplot(121); imshow(I); title('original')
subplot(122); imshow(T); title('segmented')
disp('number of segments ='); disp(K)
i have more than 100 images and i want read them at this code and get the output of segmenation on new folder on my pc
please please can you help me?????
1 comentario
Image Analyst
el 10 de Oct. de 2019
Categorías
Más información sobre Image Sequences and Batch Processing en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!