Question

[fname1 path] = uigetfile('*.*','open image file');%*.*
[path,name,ext,ver] = fileparts(fname1);
handles.fname = strcat(name,ext);
a = imread(handles.fname);
r = imresize(a,[256,256]);
file = 'C:\Main CBIR\query images\r.bmp';
[fname,map] = rgb2ind(r,32);
imwrite(fname,map,file);

Above code saves image(BMP) with name r in specified path/folder. But how to save image with its own name? I mean if i input image with name rose.jpg how to save rose.bmp using above code? instead above code saves image with r.bmp. How can i go for it?

Was it helpful?

Solution

You have the file name (e.g., 'rose') stored in variable name returned from fileparts. you can use it to create the new file name:

file = fullfile( 'c:', 'Main CBIR', 'query images', [name, '.bmp'] );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top