フィルターのクリア

if i have image with size(n,m) how can i make it to be (n,n)?

3 ビュー (過去 30 日間)
Firas Al-Kharabsheh
Firas Al-Kharabsheh 2016 年 5 月 6 日
編集済み: Image Analyst 2016 年 5 月 6 日
if i have an image and after i convert it to a binary matrix with size (n,m)
how can i make the size of this matrix to be (n,n) matrix ??
i hope to be my question clear , Thanks in advance
  2 件のコメント
John D'Errico
John D'Errico 2016 年 5 月 6 日
Not clear at all.
You can either delete some columns or add some columns, whatever it takes to make the same number of columns as you have rows. If you add new columns, you can put whatever you want in them.
Or you can use interpolation, so a tool like interp2. Of course this a a binary array, so interpolation may not be terribly meaningful. You would then probably want to round the results to convert back to binary.
Firas Al-Kharabsheh
Firas Al-Kharabsheh 2016 年 5 月 6 日
I need a function to do this because the image will be change

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

採用された回答

Image Analyst
Image Analyst 2016 年 5 月 6 日
編集済み: Image Analyst 2016 年 5 月 6 日
Try this resizing and see if it does what you want:
squareImage = imresize(rectangularImage, [n, n]);
Otherwise you can crop off the right hand side if m > n
squareImage = rectangularImage(:, 1:n);
or use padarray() or concatenation to add columns if m < n.
blankStrip = zeros(n, m-n+1, class(rectangularImage));
squareImage = [rectangularImage, blankStrip];
It would be good in the future if you thought carefully about what you ask, and phrase it properly, so that we can give you the one single answer you want, and we do not have to guess and give you all possible answers because your question was unclear/ambiguous.

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by