フィルターのクリア

Image cropping same portion from every side

4 ビュー (過去 30 日間)
Priyanka Roy
Priyanka Roy 2015 年 4 月 23 日
コメント済み: Image Analyst 2015 年 4 月 23 日
I have a image
i want to crop the image such a way that same area is cropped from each 4 sides. like :
and then at the end i'll get the result image as
how will i do this?
how to use imcrop() function here?

回答 (2 件)

Image Analyst
Image Analyst 2015 年 4 月 23 日
You can use imcrop like this:
[rows, columns, numberOfColorChannels] = size(rgbImage);
n = 40;
croppedImage = imcrop(rgbImage, [n, n, columns - 2*n, rows - 2 * n);
The above code works for either an RGB full color image, or a gray scale image.
Or you can use indexing. For a full color image, you can do
croppedImage = rgbImage(n:rows-2*n, n:columns-2*n, :); % For RGB image
Or, for a gray scale image:
croppedImage = grayScaleImage(n:rows-2*n, n:columns-2*n); % For a gray scale image
  1 件のコメント
Image Analyst
Image Analyst 2015 年 4 月 23 日
If you need to figure out what n is , then that's a different question than how to crop an image.

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


Stalin Samuel
Stalin Samuel 2015 年 4 月 23 日
編集済み: Stalin Samuel 2015 年 4 月 23 日
n=50
[r c] = size(a)%%a is the input image
eim = a(n:r-n,n:c-n) %%eim croped image
  1 件のコメント
Priyanka Roy
Priyanka Roy 2015 年 4 月 23 日
what is s & m here?

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

カテゴリ

Help Center および File ExchangeGeometric Transformation and Image Registration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by