Code Monkey home page Code Monkey logo

rgb2amiga's People

Contributors

pixinn avatar timfel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

timfel

rgb2amiga's Issues

Image map to Amiga palette is incorrect

Right now this is using ImageMagick's quantization to reduce the number of colors in the image, after mapping the entire image to Amiga's 4096 color colorspace. But quantization can (and does) introduce mix colors again that are not part of the Amiga colorspace. So the resulting CPalette in the CChunkImage is actually not guaranteed to include only colors available on the Amiga. This is "sort of" fixed later when those colors again get converted in libamivideo, but it produces results that are less optimal than what ImageMagick could achieve.

IMO, the "correct" way to do this is to

  • quantize the input to N colors
  • get the unique colors
  • create an Magick::Image as a colormap and fill it with the unique colors
  • map the colors in that colormap to the nearest Amiga colors
  • quantize the original image but this time using the map function with the colormap as input

Something like this (in CChunkyImage::Init)

  _imageRGB = img;
 
  // Constrain the colors to the provided Palette. We cannot only use the
  // default quantization, because that will introduce colorshifts to better
  // represent neighbouring pixel regions, it does not respect the colors
  // already in the image.
  _imageRGB.quantizeColors(nbColors);
  _imageRGB.quantizeDither(dither);
  _imageRGB.quantizeDitherMethod(Magick::FloydSteinbergDitherMethod);
  //_imageRGB.orderedDither("o3x3,2");
  _imageRGB.quantize();
  // now map the color reduced image using a map that only contains valid Amiga colors
  CPalette quantizedPalette = CPaletteFactory::GetInstance().GetUniqueColors(_imageRGB);
  Image map(Geometry(quantizedPalette.size(), 1), "white");
  MagickCore::PixelPacket* pixel = map.getPixels(0, 0, map.size().width(), map.size().height());
  for (std::size_t i = 0u; i < quantizedPalette.size(); ++i)
  {
    const auto nearestAmigaColor = paletteSpace.GetNearestColor(quantizedPalette[i]);
    pixel->red = nearestAmigaColor.r << (8 * (sizeof(pixel->red) - 1));
    pixel->green = nearestAmigaColor.g << (8 * (sizeof(pixel->green) - 1));
    pixel->blue = nearestAmigaColor.b << (8 * (sizeof(pixel->blue) - 1));
    ++pixel;
  }
  map.syncPixels();
  // map again from the original, which can potentially match slightly better
  _imageRGB = img;
  _imageRGB.map(map, dither);

  _palette = CPaletteFactory::GetInstance().GetUniqueColors(_imageRGB);

I can open a PR, but I have other changes in my fork now that I'll need to factor out

Release build missing DLLs

Hi,

The build you have in releases does not start. There are missing DLLs:

CORE_RL_bzlib_.dll
CORE_RL_lcms_.dll
CORE_RL_lqr_.dll

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.