how to create columns in a image
조회 수: 1 (최근 30일)
이전 댓글 표시
i have more number of rows in an image so for equalizing with columns i need to add some columns can any one suggest .
댓글 수: 3
채택된 답변
Image Analyst
2015년 11월 9일
You can just assign some lower right row,column and it will extend the canvass to the right, and below with zeros:
grayImage = imread('cameraman.tif'); % Originally 256x256
size(grayImage) % Show size in command window.
% Expland image to be 400 by 600 by padding with zeros.
grayImage(400, 600) = 0;
imshow(grayImage);
size(grayImage) % Show size in command window.
Alternatively, if you want to expand the canvass on all sides, you can use padarray().
댓글 수: 2
Image Analyst
2015년 11월 10일
You must know, or be able to determine through some algorithm, the number of rows and columns. It can still be varying but in the end, they end up with some value, right? Like they might be 400x600 one time, and 480x640 the next time, but you still must know what they are. Even if you get random sizes by using randi(), you still know what they are.
추가 답변 (1개)
Walter Roberson
2015년 11월 9일
[r, c, ~] = size(YourImage);
if r > c
YourImage(r,r,:) = 0; %extend it with 0's
end
댓글 수: 2
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!