New answers tagged

1

g = 2.2; grid = Union @@ ImageData[myImage]; gGrid = grid^g; dists[cols_] := Sqrt[Total[Power[# - ConstantArray[gGrid, 4], 2], {3}]] &[ MapThread[Outer[Times, ##] &, {cols.Transpose[gGrid]/Total[cols^2, {2}], cols}]]; Above, dists computes the (gamma uncorrected RGB) distance from each pixel color in the image to each of the colors in its ...


1

The ColorQuantize approach is nice but it doesn't given you any control over how to decide which pixel becomes what color. Here's a different approach using ColorDistance which is of comparable speed to the ColorQuantize approach and somewhere around 5x faster than the approach given by @flinty. img = Import["https://i.stack.imgur.com/q9Q5A.png"]; ...


1

This technique comparing the pixel hues in HSB to a list of known hues seems to produce much better masks than my ColorQuantize approach: img = Import["https://i.stack.imgur.com/q9Q5A.png"] // ImageAdjust; himg = ColorConvert[img, "HSB"]; cols = ColorConvert[{Red, Yellow, Green, Blue}, "HSB"]; diffHue[c1_, c2_] := .5 - Abs[Abs[...


2

The simple way to desired mix of im3d is following: redCubes = RandomInteger[1, {3, 3, 3}] greenCubes = RandomInteger[-1, {3, 3, 3}] cbs = Evaluate@(redCubes + greenCubes) /. {1 -> Red,-1 -> Green,0 -> Transparent}


2

You can use ColorQuantize with a list of preferred colours: Remove["Global`*"] img = ImageAdjust@Import["https://i.stack.imgur.com/q9Q5A.png"]; cols = {Red, Yellow, Green, Blue}; cq = RemoveAlphaChannel@ ColorQuantize[img, Append[cols, Black], Dithering -> False]; planes = With[{imd = Round@ImageData@cq}, Table[Image[Map[Boole[# ==...


1

Use Graphics3Dfor your purpose. Then create some positions where you want to place red and green cubes: datr = RandomInteger[{0, 5}, {50, 3}]; datg = RandomInteger[{0, 5}, {50, 3}]; Then determines the overlap and subtract the overlap: overlap = Intersection[datr, datg]; datr0 = Complement[datr, overlap]; datg0 = Complement[datg, overlap]; Finally draw the ...


Top 50 recent answers are included