How do you create a test image containing a ramp edge?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
This is the ideal solution
this is my solution with the following (amateur approach) code:
I = uint8(zeros(40,150));
I(:,100:150) = 128;
X2=uint8(0:49);
X3=uint8(50:99);
Y=uint8(0:39);
I(:,50:99)=meshgrid(X2,Y);
I(:,100:149)=meshgrid(X3,Y);
figure, imshow(I), title("ramp edge")
0 commentaires
Réponse acceptée
DGM
le 2 Déc 2022
Modifié(e) : DGM
le 3 Déc 2022
Here's one way.
outpict = zeros(1,150,'uint8'); % a blank vector
outpict(50:99) = linspace(0,128,50); % add a linear ramp in the middle
outpict(100:end) = 128; % fill the end
outpict = repmat(outpict,[40 1]); % replicate it
imshow(outpict)
Here's a different way:
outpict = linspace(0,150*128/50,150); % a 1D linear ramp at the appropriate slope
outpict = min(outpict-49*128/50,128); % truncate it
outpict = uint8(repmat(outpict,[40 1])); % replicate it
imshow(outpict)
outpict = lingrad([40 150],[0 1/3; 0 2/3],[0; 128],'linear','uint8');
imshow(outpict)
... which is generally more flexible.
See also:
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Introduction to Installation and Licensing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!