Missing segments in ConnectedComponentSegmentation

Hi,

I have found an odd behaviour of ConnectedComponentSegmentation. I use it to get the coastline from orthophoto images. First, I compute the NDWI index inside a buffer area close to a previous coastline and then I apply a thresholding.
NDWI_290125.tiff (181.5 KB)

I’m working on Debian 20.04.3 LTS and I call OTB 7.4.0 from Jupyter.

The NDWI image has been rescaled to a byte value, between 0 and 255. This is the NDWI image. I have found that water (or wet sand) corresponds to a pixel value greater than 152. With this threshold I get the water areas in purple in the next image. You can see that some detached wave breakers have not been detected.

app = otb.Registry.CreateApplication("ConnectedComponentSegmentation") 
app.SetParameterString("in", "/mnt/dades/costa/NDWI/NDWIc_"+full+".tif") 
app.SetParameterString("expr", "p1b1>152") 
app.SetParameterInt("minsize", 100) 
app.SetParameterString("out", "/mnt/dades/costa/trams/CC_"+full+".gpkg")  
app.ExecuteAndWriteOutput() 

When I search for ground with the complementary threshold, pixel values smaller than 152, I get the missing areas (ground polygons in pink in the following image).

app = otb.Registry.CreateApplication("ConnectedComponentSegmentation") 
app.SetParameterString("in", "/mnt/dades/costa/NDWI/NDWIc_"+full+".tif") 
app.SetParameterString("expr", "p1b1>152") 
app.SetParameterInt("minsize", 100) 
app.SetParameterString("out", "/mnt/dades/costa/trams/CCS_"+full+".gpkg")  
app.ExecuteAndWriteOutput() 
) 

What I’m doing wrong?
polygons_290125.tiff (264.6 KB)

Dear @arruga,

I’m not sure why this happens. Is the parameter minsize set to a value too low?

Would you share with us an example of “NDWIc_XXX.tif” file? The file you shared (NDWI_290125.tif) doesn’t seems to correspond to what you said (water pixel with value greater than 152).

Since you don’t take advantage of the OBIA capability of the ConnectedComponentSegmentation, why don’t you use the Segmentation application with the filter parameter set to cc?

app = otb.Registry.CreateApplication("Segmentation") 
app.SetParameterString("in", "/mnt/dades/costa/NDWI/NDWIc_"+full+".tif") 
app.SetParameterString("filter", "cc") 
app.SetParameterString("filter.cc.expr", "p1b1>152") 
app.SetParameterString("mode", "vector")
app.SetParameterString("mode.vector.out", "/mnt/dades/costa/trams/CC_"+full+".gpkg")  
app.ExecuteAndWriteOutput() 

Sincerely.
Julien.

Hi Julien,

I have also tried Segmentation with filter cc but I have other problems with it: It is very slow and generates a very big output file in geopackage format (11703590912 bytes). In shape format it raises an error.

I have noticed now that the input file had band type Float32 instead of Byte. After changing that to uint8 the results are almost the same (only the tiling has changed). Here you have a link to the image:

https://icgccat-my.sharepoint.com/:i:/g/personal/a_ruiz_g_icgc_cat/ER0LpPc8ovhBouvW6jylo58BB92U8gRCqAdUmN33hLZD4g?e=LLjaqN

Best regards,

Toni

Well, I can reproduce your results, and I don’t know why this wave breakers are not segmented correctly. I am investigating this.