How to generate a triangular datasset in matlab
Afficher commentaires plus anciens
The code above is generate vertical and horizontal lines. I want to generate in the same way two types of triangular, one straight and one upside down. I want to get triangulars similiar to that:
I will thank for your help how to do this.
The code:
close all clear
horFolder = 'C:\Users\HorVer_Dataset\0'; verFolder = 'C:\Users\HorVer_Dataset\1';
N = 1000 ;
for indx=1:N
I = uint8 ( zeros (80, 80 ) ) ;
lineX = round(10 + rand*60) ;
lineY = round(10 + rand*60) ;
lineW = round(1 + rand) ;
lineH = round(15+20*rand) ;
if rand < 0.5
lineDirection = 'H' ;
imageFolder = horFolder ;
xRange = max(1, (lineY-round(lineH/2))):min(80, (lineY+round(lineH/2))) ;
yRange = max(1, (lineX-round(lineW/2))):min(80, (lineX+round(lineW/2))) ;
else
lineDirection = 'V' ;
imageFolder = verFolder ;
xRange = max(1, (lineX-round(lineW/2))):min(80, (lineX+round(lineW/2))) ;
yRange = max(1, (lineY-round(lineH/2))):min(80, (lineY+round(lineH/2))) ;
end
I(yRange, xRange) = 255 ;
indxStr = num2str(indx) ;
while length(indxStr) < 4
indxStr = [ '0' indxStr ] ;
end
imageFileName = [ imageFolder, '\Line', indxStr, '.png' ] ;
imwrite ( I, imageFileName ) ;
% figure % imshow (I) end
Réponses (0)
Catégories
En savoir plus sur Logical 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!