Saving the image names and bounding box coordinates in different file formats

조회 수: 1 (최근 30일)
I've written a Matlab code to crop an image with respect to a mask.
function Crop_Img = Crop_Xray(Img,Mask)
% Find borders
vertical_profile = sum(Mask,2);
horizontal_profile = sum(Mask);
indexes = find(vertical_profile >0);
upper = indexes(1);
lower = indexes(end);
indexes = find(horizontal_profile > 0);
left = indexes(1);
right = indexes(end);
% Crop Img
Crop_Img = Img(upper:lower, left:right);
end
I would like to save the individual image file names (*.png) and their respective bounding box coordinates (upper:lower, left:right) to a .csv, .txt, and .mat file. How should I do that?

채택된 답변

Image Analyst
Image Analyst 2018년 8월 17일
Try this:
save('Crop_Img.mat', 'upper', 'lower', 'left', 'right');
imwrite(Crop_Img, 'Crop_Img.png');
Change the filename if you want.
  댓글 수: 2
Sivaramakrishnan Rajaraman
Sivaramakrishnan Rajaraman 2018년 8월 17일
My requirement is to save the image name and the respective bounding box coordinates in adjacent columns.
Image Analyst
Image Analyst 2018년 8월 17일
So make a table with the table() function and save that. Look up the table() function in the help for sample code.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by