Skip to content
\n\n

The example images I use are geoTIFF files which have a negative color-band range (e.g. this example .tif with min: -4123.31 and max: -4061.37; information derived from QGIS, see screenshot below).
\nI am able to get the max-value of the image correctly via $vipsImage->max(). The $vipsImage->min() returns -99999. However, I would like to get the min-value of the true image pixels (-4123.31), as with the current setup, I get a black&white image with binary values (either 0 or 255) instead of a gray-scale image.
\n\"QGIS_information_tab\"

\n

So my question is, how could I get the min-value of the true pixel values of the geoTIFF and disregard the NoData pixel values.

\n

Any help to achieve this is greatly appreciated! Thanks in advance for your time and effort.

","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"

Hello @mtiessen1175,

\n

Do you have a sample image you could share?

\n

If you want to find the min and exclude -99999, it's probably easiest to set the -99999s to 0 (or some very high value?) before searching for min. Perhaps (untested):

\n
$min = $image->equal(-99999)->ifthenelse(0, $image)->min();
\n

You can speed it up with stats(). This will make a single pass over the image and find max and min together.

\n

You could also call linear() directly. This computes y = a * x + b, so you can replace your -, /, * with a single call.

","upvoteCount":1,"url":"https://github.com/libvips/php-vips/discussions/250#discussioncomment-11152748"}}}

Normalize color band #250

Answered by jcupitt
mtiessen1175 asked this question in Q&A
Nov 4, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Hello @mtiessen1175,

Do you have a sample image you could share?

If you want to find the min and exclude -99999, it's probably easiest to set the -99999s to 0 (or some very high value?) before searching for min. Perhaps (untested):

$min = $image->equal(-99999)->ifthenelse(0, $image)->min();

You can speed it up with stats(). This will make a single pass over the image and find max and min together.

You could also call linear() directly. This computes y = a * x + b, so you can replace your -, /, * with a single call.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mtiessen1175
Comment options

Answer selected by mtiessen1175
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants