(Important )How to generate numbers in matlab? Need help.
Afficher commentaires plus anciens
Hi everyone. I have a question. I want to make an automatic image rescaling using a random number as follow. How can i make it so that xb variable will be bigger than xa variable as the function randscale stated than xb cannot be same and bigger than xa? I think using linspace also gives me error. Thanks for helping.
clear;
clc;
img1 = imread('peppers.png');
data=100;
for i=1:data
xmin=0.001;
xmax=1;
n=data;
xa=fliplr(round(xmin+linspace(1,n)*(xmin+xmax)));
xb=round(xmin+linspace(1,n)*(xmax-xmin));
augmenter = imageDataAugmenter('RandScale',[xa xb]);
S=augment(augmenter,img1);
imwrite(S, [pathname '\' fol '_imagescaling' num2str(i) '.png']);
end
Réponse acceptée
Plus de réponses (1)
yanqi liu
le 10 Nov 2021
clc; clear all; close all;
img1 = imread('peppers.png');
data=100;
for i=1:data
xmin=0.001;
xmax=1;
% n=data;
% xa=fliplr(round(xmin+linspace(1,n)*(xmin+xmax)));
% xb=round(xmin+linspace(1,n)*(xmax-xmin));
rate = sort(abs(randn(1, 2)));
augmenter = imageDataAugmenter('RandScale',rate);
S=augment(augmenter,img1);
imwrite(S, [pathname '\' fol '_imagescaling' num2str(i) '.png']);
end
1 commentaire
Catégories
En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!