필터 지우기
필터 지우기

How to crop 1 inch

조회 수: 14 (최근 30일)
pizzaa
pizzaa 2023년 7월 3일
댓글: pizzaa 2023년 7월 4일
I want to crop an image with 1 inch for every side, i dont know kow much pixel 1 inch in matlab so
How do i crop an image with 1 inch or 2,54 cm.
Can someone provide the code?
  댓글 수: 1
Rik
Rik 2023년 7월 3일
You will need to know the resolution of your image in terms of dpi (/ppi): dots per inch. That is sometimes stored in the image metadata, but otherwise is something you will have to determine yourself.

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2023년 7월 3일
You will need to know how many pixels per inch there are. You can do this by drawing a line along some object in your image that has a known size in inches. See attached spatial calibration demo.
  댓글 수: 1
pizzaa
pizzaa 2023년 7월 4일
ty too image analyst, ur a god

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Ludo Houben
Ludo Houben 2023년 7월 3일

Sushma Swaraj
Sushma Swaraj 2023년 7월 3일
Hi, We use the 'imcrop' function to crop an image.
% Read the image
image = imread('your_image.jpg'); % Replace 'your_image.jpg' with the file path of your image
% Get the image size in pixels
[height, width, ~] = size(image);
% Calculate the desired margin size in pixels
marginInches = 1; % 1 inch margin
pixelsPerInch = get(0, 'ScreenPixelsPerInch'); % Get the screen resolution in pixels per inch
marginPixels = round(marginInches * pixelsPerInch); % Convert inches to pixels
% Calculate the crop region
cropRect = [marginPixels + 1, marginPixels + 1, width - 2*marginPixels, height - 2*marginPixels];
% Crop the image
croppedImage = imcrop(image, cropRect);
% Display the cropped image
imshow(croppedImage);
Hope it helps!
  댓글 수: 1
pizzaa
pizzaa 2023년 7월 4일
편집: pizzaa 2023년 7월 4일
Thanks ur a beast

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by