How do you create a test image containing a ramp edge?
조회 수: 9(최근 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;
figure, imshow(I), title("ramp edge")
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
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
Or if you're using MIMT, you can just do
outpict = lingrad([40 150],[0 1/3; 0 2/3],[0; 128],'linear','uint8');
... which is generally more flexible.