3
$\begingroup$

This is the first time I use Mathematica to do image processing, and I just want to remove the coordinate axes from this image.

Initially, I obtained the coordinates of the bottom-left corner as approximately (8,6) and the coordinates of the top-right corner as (28,22).

However, when I applied ImageTrim, it resulted in a blank image.

Could there be a mistake in my understanding of this?

By the way, why my output of imported image is so small?

Thank you.

i = Import["C:\\image-xF-bw.png"]
ImageTrim[i, Rectangle[{8, 6}, {28, 22}]]

image-xF-bw.png blank output bottom-left point coordinate top-right point cooridnate

$\endgroup$
1

2 Answers 2

5
$\begingroup$

The displaying size of an Image[…] is influenced by ImageResolution option:

enter image description here

So are the coordinates obtained by [Right-click] ▶ Get Coordinates. At least in version 14, the coordinates will be consistent with the standard image coordinate system (the coordinate system used by ImageTrim, etc., see the Details and Options section of ImageTrim for more info) when ImageResolution -> 72:

img = Import["https://i.sstatic.net/211uP.png"];
Image[img, ImageResolution -> 72]

enter image description here

Alternatively, using a Graphics to wrap the Image[…] will also transform the coordinates to the standard image coordinate system:

Graphics[img, Axes -> True]

enter image description here

With either of the methods above, the correct coordinates can be obtained:

enter image description here

$\endgroup$
1
  • $\begingroup$ Wow, so much useful information. I'll digest it thoroughly. Thank you so much! $\endgroup$
    – xinxin guo
    Commented Mar 4 at 8:16
3
$\begingroup$
img = Import["https://i.sstatic.net/211uP.png"]

First get the ImageDimensions:

ImageDimensions[img]

{498, 406}

ImageTrim[img, {{120, 100}, {480, 360}}]

These coordinates are {x1,y1}, {x2,y2} (lower left, upper right).


or you could try:

ImageTake[img, {40, 300}, {120, 480}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.