TransWikia.com

ImageData of an image section

Mathematica Asked on August 13, 2021

How can I take the image data of the area around a max?

img = Import["https://i.stack.imgur.com/YDCGF.png"]
markers = MaxDetect[GaussianFilter[img, 10], Padding -> 1]; 
HighlightImage[img, markers, Method -> {"DiskMarkers", 5}]

image

image with marker

I would like to take the image data of the shape it is within like:

image with border

Update: I made a brute force version using ImageTrim[] and PixelValuePositions[] but this is just using a approximate square around the max detect point

One Answer

I am not sure I understand exactly what is required but I'll try something. In the last image all pixels are set to 0 except in the areas of interest (where the pixels of the original image are shown).

img = Import["https://i.stack.imgur.com/YDCGF.png"]
markers = MaxDetect[GaussianFilter[img, 10], 0.03, Padding -> 1]
comp = ImageMultiply[img, markers]
data = ImageData[comp];

enter image description here

Correct answer by Jean-Pierre on August 13, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP