accessing pixel value of a point

I transformed the image from the index to the physical point.
Now I want to apply a certain condition to the pointset and set the corresponding pixel value to a new value.

I know that we can access or set pixel value through

image->GetPixel(pixelIndex);
image->SetPixel(pixelIndex, pixelValue);

I want to know a way of accessing the pixel value of a point and set it to a new value.

Hello @EE18D504_SINDHURA_C,

The method you are looking for is TransformPhysicalPointToIndex:

image->SetPixel(image->TransformPhysicalPointToIndex(myPoint), pixelValue);

One thing to note, the returned index may be outside the image bounds, so SetPixel may throw an exception. It all depends on the parameter value myPoint, as long as it is inside the image bounds you are ok.

2 Likes