Borrar filtros
Borrar filtros

How to crop 1 inch

14 visualizaciones (últimos 30 días)
pizzaa
pizzaa el 3 de Jul. de 2023
Comentada: pizzaa el 4 de Jul. de 2023
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 comentario
Rik
Rik el 3 de Jul. de 2023
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.

Iniciar sesión para comentar.

Respuesta aceptada

Image Analyst
Image Analyst el 3 de Jul. de 2023
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 comentario
pizzaa
pizzaa el 4 de Jul. de 2023
ty too image analyst, ur a god

Iniciar sesión para comentar.

Más respuestas (2)

Ludo Houben
Ludo Houben el 3 de Jul. de 2023

Sushma Swaraj
Sushma Swaraj el 3 de Jul. de 2023
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 comentario
pizzaa
pizzaa el 4 de Jul. de 2023
Editada: pizzaa el 4 de Jul. de 2023
Thanks ur a beast

Iniciar sesión para comentar.

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by