Bandmath_Subtraction

I have a noisy water mask extracted from SAR. Using the bandmath-subtraction from the speckled mask (water bodies excluded), but the outcome doesnt produce the water bodies. I thought that the extraction would solve the problem though.

How can I extract just water bodies from a noisy mask band including roads,…?

Thanks

to reduce the single misclassified pixels you could also apply a minimum filter by right-clicking on the band > Filter band > Minimum 3x3.

1 Like

I did try it, but it doesnt remove it all. The second band mask that I have is all noise and unwanted areas which I like to subtract it from my main water mask image. I dont really know why the subtraction didnt work properly.

hard to tell why it is not working.
Does the data consist of 1 and 0 only?
Integer or float?
Are the dimensions exactly the same?

1 Like

Yes, both mask bands are extracted from the same db SAR image. the First mask is “db band range” and the second one is a “detect line filter (e.g., Roberts Cross N-E)”.

did you have a look at the layer statistics of both rasters? Min/max would be important, also the nodata value.

1 Like

The Min values are not the same.

did you chec at which pixels exactly the result is 2? Makes no sense to me either…

can you upload the two rasters somewhere?

1 Like

I have tried to upload my two mask bands here, but its size 4MB is too large.

you could clip it to a small extent. It doesn’t need to be complete.

1 Like

Desktop.zip (1.4 MB)

Enclosed is the zip file including two bands which need to be subtracted. Thanks

I found that one of your data is 0 and 255, the other is 0, 254 and 255. In your example, those were 0 and 1 but I guess there were more than just two values resulting in at least 3 different values in your results.

1 Like

Thanks a lot. Is there any way to fix it?

band maths:
if new_band_1_S == 254 then 255 else new_band_1_S

converts 254 to 255, leaves all other values as they are.

1 Like

I did the same. But the result of subtraction would remain the same!

that is because - according to your screenshots - you don’t have 254 as a value. Have a close look at your data to see which values your raster consists of and then reclassify the ones you don’t want - it’s simple maths :slight_smile:

1 Like