フィルターのクリア

how to create columns in a image

3 ビュー (過去 30 日間)
Ram
Ram 2015 年 11 月 9 日
コメント済み: Image Analyst 2015 年 11 月 10 日
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 件のコメント
Guillaume
Guillaume 2015 年 11 月 9 日
Explain better what you want to do.
  • Add columns of black (white?) to the image?
  • resize the image so that it has a square aspect ratio?
  • something else?
Ram
Ram 2015 年 11 月 9 日
i am having empty rows & columns in which number of empty rows are more.I want to add some additional columns such that number of empty rows & empty columns are same.

サインインしてコメントする。

採用された回答

Image Analyst
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 件のコメント
Ram
Ram 2015 年 11 月 10 日
In the solution provided rows & columns are given manually but if i want to add varying number of columns for different template images then
Image Analyst
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
Walter Roberson 2015 年 11 月 9 日
[r, c, ~] = size(YourImage);
if r > c
YourImage(r,r,:) = 0; %extend it with 0's
end
  2 件のコメント
Ram
Ram 2015 年 11 月 9 日
its not creating additional columns as required
Guillaume
Guillaume 2015 年 11 月 9 日
編集済み: Guillaume 2015 年 11 月 9 日
You need to be clearer as to what is required then,
Walter's code will create additional columns. It also does not lose any information. It just adds columns of black.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGet Started with Image Processing Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by