Input_folder = Output_folder = D = dir([Input_folder '*.jpg']); Inputs = {D.name}'; Outputs = Inputs; % preallocate %print(length(Inputs)); for k = 1:length(Inputs) X = imread([Input_folder Inputs{k}]); dotLocations = find(Inputs{k} == '.'); name_img = Inputs{k}(1:dotLocations(1)-1); image1=im2bw(X); vec = [3;6;10]; vec_l = length(vec); for i = 1:vec_l %se = strel('disk',2); fprintf(num2str(vec(i))); se = strel('diamond',vec(i)); %imdilate im = imdilate(image1,se); image2 = im - image1; Outputs{k} = regexprep(Outputs{k}, name_img, strcat(name_img,'_', num2str(vec(i)))); imwrite(image2, [Output_folder Outputs{k}]) end end
As it can be seen, I would like to apply dilation with parameters 3,6 and 10. Let us assume that an image has as name "image1", after processing it, I would like to have "image1_3", "image1_6" and "image1_10". However, I am getting as results "image1_3", "image1_6_3" and "image1_10_6_3". Please, how can I modify my codes to fix this problem?
Input_folder = Output_folder = S = dir(fullfile(Input_folder,'*.jpg')); for ii = 1:numel(S) F = S(ii).name; X = imread(fullfile(Input_folder,F)); I = im2bw(X); [~,N,E] = fileparts(F); V = [3;6;10]; for jj = 1:numel(V) se = strel('diamond',V(jj)); %imdilate J = imdilate(I,se); Y = I - J; G = sprintf('%s_%d%s',N,V(jj),E); imwrite(Y,fullfile(Output_folder,G)) end end
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.