PixelValuePositions

PixelValuePositions[image,val]

returns a list of pixel positions in image that exactly match the value val.

PixelValuePositions[image,val,d]

returns all pixel positions that have values within a distance d from val.

Details

  • PixelValuePositions finds and returns pixels of specific values in 2D and 3D images and is typically used for locating features or removing artifacts.
  • PixelValuePositions assumes a pixel-aligned coordinate system that is shifted by 0.5 to the left and down with respect to the standard image coordinate system.
  • Use ImageValuePositions to get positions in the standard image coordinate system.
  • The pixel value val can be in one of the following forms:
  • sa scalar
    colora color
    {s1,s2,}a list of channel values
    "Max"pixels with maximum intensity
    "Min"pixels with minimum intensity
  • In 3D, PixelValuePositions[image,val] returns the positions {xp,yp,zp}, such that pixel position corresponds to the center of the bottom-left front pixel.

Examples

open allclose all

Basic Examples  (3)

Extract positions of the white pixels:

Positions of the pixels with values within the specified distance from white:

Positions of white pixels in a 3D image:

Scope  (4)

Positions of the pixels with maximum intensity:

Positions of the pixels with minimum intensity:

Positions of red pixels:

Positions of the pixels with values within the specified distance from red:

Applications  (2)

Extract data coordinates in an image:

Find a best-fit sine function:

Extract coordinates of annotations in a document:

Make the handwritten annotations disappear:

Properties & Relations  (2)

PixelValuePositions[image,val] is equivalent to PixelValuePositions[image,val,0]:

PixelValuePositions[image,val] is equivalent to ImageValuePositions[image,val] plus :

Wolfram Research (2012), PixelValuePositions, Wolfram Language function, https://reference.wolfram.com/language/ref/PixelValuePositions.html.

Text

Wolfram Research (2012), PixelValuePositions, Wolfram Language function, https://reference.wolfram.com/language/ref/PixelValuePositions.html.

CMS

Wolfram Language. 2012. "PixelValuePositions." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/PixelValuePositions.html.

APA

Wolfram Language. (2012). PixelValuePositions. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PixelValuePositions.html

BibTeX

@misc{reference.wolfram_2024_pixelvaluepositions, author="Wolfram Research", title="{PixelValuePositions}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/PixelValuePositions.html}", note=[Accessed: 12-October-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_pixelvaluepositions, organization={Wolfram Research}, title={PixelValuePositions}, year={2012}, url={https://reference.wolfram.com/language/ref/PixelValuePositions.html}, note=[Accessed: 12-October-2024 ]}