I would like to modify a gray scale image so the black background turns transparent and the white pixels go to a purple color. I attached the image, my attempt to turn the white pixels in the image to purple without changing the black background, and my attempt to change the background from black to white.
It seems like when I try to remove the black background and convert it to white, the end image looks very choppy. It seems like I can't maintain the "wispyness" of the original grayscale image and the purple to white cutoff is harsher. I tried using some GaussianFilters to smooth out the transition but would really like to just convert the original image properly so that filters are not necessary as they are not having the effect I want
Code to convert to purple:
(*imD is original grayscale image matrix*) Colorize[Image[imD], ColorFunction -> Function[gray, RGBColor[93/255 gray, 0, (gray)]]]
Code to convert to white background:
ColorReplace[ Colorize[Image[imD, ImageSize -> Scaled[0.2]], ColorFunction -> Function[gray, RGBColor[93/255 gray, 0, gray]]], Black -> White]
Image converted to purple
Attempt at background subtraction