| 51 | |
| 52 | |
| 53 | void Viewer::DoQuantizeInterface(int& method, int& spatialFilterSize, float& spatialDitherLevel, int& neuSampleFactor, float itemWidth) |
| 54 | { |
| 55 | if (itemWidth > 0.0f) |
| 56 | ImGui::SetNextItemWidth(itemWidth); |
| 57 | |
| 58 | const char* methodItems[] = { "Fixed Palette", "Spatial Scolorq", "Neu Quant", "Wu Bipartition" }; |
| 59 | ImGui::Combo("Quantize Method", &method , methodItems, tNumElements(methodItems)); |
| 60 | ImGui::SameLine(); |
| 61 | Gutil::HelpMark |
| 62 | ( |
| 63 | "The colour quantization method is used to create a high-quality palette.\n\n" |
| 64 | |
| 65 | "Fixed Palette: Lowest quality since it doesn't inspect the image pixels.\n" |
| 66 | "Useful for 1-bit (2-colour) palettes as it guarantees black and white\n" |
| 67 | "are present. No guarantee that the number of colours requested will all\n" |
| 68 | "be used because the source image colours may not be close to all the\n" |
| 69 | "colours in the fixed palette.\n\n" |
| 70 | |
| 71 | "Spatial Scolorq: High quality but slow. Good for 5-bit (32-colour)\n" |
| 72 | "palettes and smaller. This quantization method supports dither.\n\n" |
| 73 | |
| 74 | "Neu Quant: Defacto high-quality quantizer. Neural-network based. Good\n" |
| 75 | "for 6-bit (64-colour) palettes and larger.\n\n" |
| 76 | |
| 77 | "Wu Bipartition: The default quantizer. Fast and looks very good at 5-bit\n" |
| 78 | "(32-colour) and higher." |
| 79 | ); |
| 80 | |
| 81 | if (method == int(tQuantize::Method::Spatial)) |
| 82 | { |
| 83 | if (itemWidth > 0.0f) |
| 84 | ImGui::SetNextItemWidth(itemWidth); |
| 85 | const char* filterSizeItems[] = { "Low", "Med", "High" }; |
| 86 | ImGui::Combo("Quantize Filter Size", &spatialFilterSize , filterSizeItems, tNumElements(filterSizeItems)); |
| 87 | ImGui::SameLine(); |
| 88 | Gutil::HelpMark("Filter size for the scolorq/spatial quantizer. Low -> 1, Med -> 3, High -> 5"); |
| 89 | |
| 90 | if (itemWidth > 0.0f) |
| 91 | ImGui::SetNextItemWidth(itemWidth); |
| 92 | ImGui::SliderFloat("Quantize Dither", &spatialDitherLevel, 0.0f, 2.0f, "%.1f"); |
| 93 | ImGui::SameLine(); |
| 94 | Gutil::HelpMark |
| 95 | ( |
| 96 | "Dither level for the scolorq/spatial quantizer. 0 means auto-determine a good value for\n" |
| 97 | "the current image based on its dimensions. Greater than zero means manually set the\n" |
| 98 | "amount. A dither value of 0.1 results in no dithering. 2.0 results in significant dithering." |
| 99 | ); |
| 100 | } |
| 101 | |
| 102 | if (method == int(tQuantize::Method::Neu)) |
| 103 | { |
| 104 | if (itemWidth > 0.0f) |
| 105 | ImGui::SetNextItemWidth(itemWidth); |
| 106 | ImGui::SliderInt("Quantize Factor", &neuSampleFactor, 1, 10, "%d"); |
| 107 | ImGui::SameLine(); |
| 108 | Gutil::HelpMark |
| 109 | ( |
| 110 | "Sample factor for the Neu quantizer. 1 is highest quality and slowest. All pixels are visited\n" |
nothing calls this directly
no outgoing calls
no test coverage detected