How do you create a test image containing a ramp edge?
조회 수: 7 (최근 30일)
이전 댓글 표시
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
채택된 답변
DGM
2022년 12월 2일
편집: DGM
2022년 12월 3일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!