threshold images and save as jpeg in loop
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
udi ibgui
le 13 Fév 2020
Réponse apportée : Subhadeep Koley
le 13 Fév 2020
Hi, I would like to run a threshold to approx 50 images of mine and then save the output as jpg, currently im not managing as the saved file says it cannot be read. below is my code
for i = 1:numel(I)
%Obtain red matrix of image
filename = fullfile(path, I(i).name);
im = imread(filename);
%Extract Red Channel
b = im(:,:,1);
%Normalising red values
Norm=double(b(:))./255;
%Reshaping to fit image shape
[f,g]=size(b);
imn=reshape(Norm,[f,g]);
%threshold image
thresh = imn .* imn>(0.6258);
thresh_im = uint8(thresh);
name = int2str(i);
save([name, '.jpg'], 'thresh_im')
end
Please help?
0 commentaires
Réponse acceptée
Subhadeep Koley
le 13 Fév 2020
for i = 1:numel(I)
% Obtain red matrix of image
filename = fullfile(path, I(i).name);
im = imread(filename);
% Extract Red Channel
b = im(:, :, 1);
% Normalising red values
Norm = double(b(:)) ./ 255;
% Reshaping to fit image shape
[f, g] = size(b);
imn = imresize(Norm, [f, g]);
% Threshold image
thresh = imn .* imn>(0.6258);
thresh_im = uint8(thresh);
% Save the image
imwrite(thresh_im, ['img', num2str(i), '.jpg']);
end
0 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!