Saving images into various folders

조회 수: 1 (최근 30일)
Abhishek Singh
Abhishek Singh 2019년 7월 19일
댓글: KALYAN ACHARJYA 2019년 7월 19일
I am working on image clustering. My algorithm reads the image set from my system into MATLAB and segregates them into different clusters based on my criteria. At the end of the algorithm I have different cluster numbers with their image index content. So if I have cluster 1 with images 1,2,3,5 for example:- Cluster{1} would return a matrix.
Cluster{1} 1 2 3 5
I was wondering if I could use some function which saves those image according to the clusters in my local machine. For example, if I have image (1,2,3,5) in cluster 1 and image (4,7) in cluster 2 then I should have two folders in my working directory named Cluster1 with image 1 2 3 5 and Cluster 2 with image 4 7. I am right now trying to include for() loop by looking at each content of each cluster{}. I tried just reading and writing the same image and it took a couple of seconds which led me to believe the loop will even slower it down. Could someone please tell me the Matrix way to do it which would be faster than this.
Please let me know if this could be achieved. Thank you in advance.

답변 (1개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 7월 19일
편집: KALYAN ACHARJYA 2019년 7월 19일
Original Question
"I am working on image clustering. My algorithm reads the image set from my system into MATLAB and segregates them into different clusters based on my criteria. At the end of the algorithm I have different cluster numbers with their image index content. I was wondering if I could use some function which saves those image according to the clusters in my local machine. For example, if I have image (1,2,3,5) in cluster 1 and image (4,7) in cluster 2 then I should have two folders in my working directory named Cluster1 with image 1 2 3 5 and Cluster 2 with image 4 7.
Please let me know if this could be achieved. Thank you in advance"
You can do this way also
Images=input images path
outDirectory1='C:\complete_path\cluster1\';
outDirectory2='C:\complete_path\cluster2\';
for i=1:.... % Image read iterration
%% Save Images
if segmented_image condition for_cluster 1 or cluster 2
%or Check from i
if cluster1
imwrite(segmented_image,strcat(outDirectory1,Images(i).name));
else %(This for cluster2)
imwrite(segmented_image,strcat(outDirectory2,Images(i).name));
end
Please Note: May be there is more easier way.
  댓글 수: 7
Abhishek Singh
Abhishek Singh 2019년 7월 19일
I can understand that, but don't you think referring images directly by calling my cluster{} function and then it saves them to the system since all are present in workspace would be faster?
KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 7월 19일
Yes

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by