ok i figured out a way with the alpha-merge filter, there's no need for the second palette that allows transparent.
so i started simply
ffmpeg -i image.png -i palette.png -filter_complex "paletteuse=dither=bayer" image2colors.png
ffmpeg -i background.png -i image2colors.png -filter_complex "alphamerge" out.png
that convert the entire image to an alpha channel(both black and white are transparent)
ffmpeg -i image2colors.png -i background.png -filter_complex "[0]split[a][b];[a][b]alphamerge[c];[1][c]overlay[d]" -map [d] out.jpeg
this keeps the color white and made the black of the drawing transparent that, when overlayed, becomes red, also the color white is not so bright anymore, like it has a sort of transparency
this solved the question
ffmpeg -i image2colors.png -i background.png -filter_complex "[0]split[a][b];[a]negate[n];[b][n]alphamerge[c];[1][c]overlay[d]" -map [d] out.jpeg
that gave me a perfect black frame on alpha-channel overlayed to a colored background.(the jpeg shows that the overlay has gone correctly)
Seems that the alpha-merge chooses the black over the white.
i'm posting all of my mistakes because i made it by attempts and i still don't know what i'm doing.
if anyone has a more elegant way to obtain this result please answer to me with a lot of details.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…