Replace a color in image with hatchfilling

Using an input example from the documentation page for ImageGraphics:

hilbert = Import["https://i.stack.imgur.com/F9aZB.png"]

enter image description here

smoothHilbert = CurvatureFlowFilter[MeanShiftFilter[hilbert, 8, 1/16], 2];

ig = ImageGraphics[smoothHilbert, 3]

enter image description here

colors = Cases[ig, {a_, _FilledCurve} :> a, All]

enter image description here

ig /. colors[[1]] -> HatchFilling[]

enter image description here

ig /. {colors[[1]] -> HatchFilling[], 
  colors[[2]] -> PatternFilling["Checkerboard", {10, 10}], 
  colors[[3]] -> HatchFilling[-45 Degree, 5, 10]} 

enter image description here


Here's a way to do it without converting the image into vectorized graphics.

hilbert = Import["https://i.stack.imgur.com/F9aZB.png"];
smoothHilbert = CurvatureFlowFilter[MeanShiftFilter[hilbert, 12, 1/16], 2];
quantizedHilbert = ColorQuantize[smoothHilbert, {Black, White, Gray}, Dithering -> False];

Mathematica graphics

whiteMask = ColorReplace[quantizedHilbert, Gray -> Black]

Mathematica graphics

{width, height} = ImageDimensions[whiteMask];
filling = Rasterize@Graphics[{
     HatchFilling[],
     Rectangle[{0, 0}, {width, height}]
     }, ImageSize -> {width, height}, PlotRangePadding -> None];

filling whiteMask + ColorNegate[whiteMask] quantizedHilbert

Mathematica graphics