Surface and length

Hello,
I have a problem. I have to write a program for designating the area and length of the edge of a color spot at the click of a mouse. I know that i must load a picture and and that the actions are after a click, but i don’t know how get the surface and edge length. Do you have an idea?

Hi @ala
Can you explain this part in more detail?
What do you mean by edge of a color spot?

so i have something like this and i must get a surface and length of edge this “spot” (circuit?) after clicking the mouse on it.

I still don’t understand what you mean.
If you want to calculate the surface area, that would be simple.
Just count how many red pixels, (or not white), in the pixel array here.
But what would be the edge? Maybe the rectangle boundary?
That’s also simple, but you have to keep track of the x and y value of the pixel array, and search for the most upper and left pixel value.
You can learn about it here:

1 Like

Hello,

This should help:

The area is proportional to the number of red pixels.

You can get the pixel locations along the edge (red to white) and get the distance between these.

I got started with some success but need to get some fresh air and sun before dark.

Think about it and then start coding this; this is a really good exercise!

I won’t be sharing my code here.

Other resources here:

:)

Maybe OP is looking for the contour length ?

Oh yes, probably. It’s in the title.
Anyway, it’s all about the pixels array. In this case, he should count the number of pixels that have different color neighbors.

1 Like