MATLAB: Hi, how to save the output to a specific folder

image processingprojectstudent

Hi, I am trying to save the output of this code but I can't seem to use imsave or imwrite.
I = imread('C:\Users\Student\Desktop\Vehicle number plate recognition\vehicles\vehicle10.jpg');
BW = im2bw(I,0.4);
se = strel('rectangle', [2 20]);
BW_opened = imclose(BW,se);
figure, imshow(BW_opened,[])
s=regionprops(BW_opened,'Area','BoundingBox');
[hh,ii] = sort([s.Area],'descend');
out = imcrop(I,s(ii(2)).BoundingBox);
figure,imshow(out);
out = 'my new image.png'; % Whatever....
fullFileName = fullfile(out, 'C:\Users\Student\Desktop\Vehicle number plate recognition\test images');
imwrite(out, fullFileName);
I would get an error of 😐 | _Error using imwrite>parse_inputs (line 528) The first argument should not be a character vector.
Error in imwrite (line 418) [data, map, filename, format, paramPairs] = parse_inputs(varargin{:});||
Error in licenseplatecrop (line 13) imwrite(out, fullFileName);_

Best Answer

I = imread('C:\Users\Student\Desktop\Vehicle number plate recognition\vehicles\vehicle10.jpg');
BW = im2bw(I,0.4);
se = strel('rectangle', [2 20]);
BW_opened = imclose(BW,se);
figure, imshow(BW_opened,[])
s=regionprops(BW_opened,'Area','BoundingBox');
[hh,ii] = sort([s.Area],'descend');
out = imcrop(I,s(ii(2)).BoundingBox);
figure,imshow(out);
out_path = 'C:\Users\Student\Desktop\Vehicle number plate recognition\vehicles'; % Give path here
fullFileName = fullfile(out_path, 'test_image.jpg');
imwrite(out, fullFileName);
Related Question