Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal colour representation #308

Closed
t0mpr1c3 opened this issue Jun 2, 2020 · 8 comments
Closed

Internal colour representation #308

t0mpr1c3 opened this issue Jun 2, 2020 · 8 comments
Assignees
Milestone

Comments

@t0mpr1c3
Copy link
Contributor

t0mpr1c3 commented Jun 2, 2020

As Chris mentioned (#297) the internal concept of colour, as implemented in ayab.plugins.ayab_plugin.ayab_image, is represented as bands of greyscale brightness.

I haven't tested it, but presumably this would not distinguish between e.g. cyan 0xFFFF00, magenta 0xFF00FF, and yellow 0x00FFFF,

It probably works fine most of the time but it does look like the type of kludge that we should probably get away from before releasing a 1.0.0 version.

Chris's suggestion of a hard limit of 4 or 6 colours seems sensible, and these few colours could be represented by integer values just as they are now, with a simple lookup table for the RGB values.

More generally, I am concerned that the reliance on a one-byte-per-stitch matrix (plus a few knitting modes) as a representation of the knitting pattern essentially restricts AYAB to rectangles of stocking stitch, in contrast to more flexible formats discussed elsewhere e.g. #299. Changing the internal representation wholesale would clearly be a massive refactoring, but as I mentioned in that thread, a more abstract representation would offer considerable advantages.

@t0mpr1c3 t0mpr1c3 changed the title Multicolour concept Internal colour representation Jun 2, 2020
@dl1com
Copy link
Contributor

dl1com commented Jun 3, 2020

I am open for a versatile concept for this. The AYABImage class has to be refactored anyway, so we can use this as a chance to make it future-proof as well.

@t0mpr1c3
Copy link
Contributor Author

t0mpr1c3 commented Jun 4, 2020

What's the most useful way I can contribute at the moment? I've been adding little features, just because that is fairly easy to do, but I would be happy to attempt some of the heavier tasks.

@t0mpr1c3 t0mpr1c3 closed this as completed Jun 4, 2020
@t0mpr1c3 t0mpr1c3 reopened this Jun 4, 2020
@dl1com
Copy link
Contributor

dl1com commented Jun 4, 2020

What's the most useful way I can contribute at the moment? I've been adding little features, just because that is fairly easy to do, but I would be happy to attempt some of the heavier tasks.

Probably we should handle #299 first, so we have a consolidated set of requirements for a holistic pattern representation, i.e. which properties of a pattern have to be handled inside the software (colors, shape, carriage, instructions, ...). Then we can dive into re-implementation of AYABImage (perhaps AYABPattern by then).
As you are definitely closer to the topic of knitting and you already made up your mind a bit about a knitting pattern format, I propose that you document some of your thoughts and (high level) requirements into #299. What do you think?

@t0mpr1c3
Copy link
Contributor Author

t0mpr1c3 commented Jun 4, 2020

Yes, I think that's a good suggestion.

@t0mpr1c3
Copy link
Contributor Author

t0mpr1c3 commented Jun 5, 2020

Following up, it looks like AYAB currently knits the palest colour first and the darkest colour last. So, if you are designing a multicolour pattern, you can choose the order in which colours are knit by changing the colours to greyscale. White will be knit first, and black last. To me it seems like a kludge, but it is potentially useful.

If we were to switch to using real colours for the internal representation, the user would not have this option. Should the user be have an option to choose the background colour by some other means?

@dl1com
Copy link
Contributor

dl1com commented Jun 7, 2020

If we were to switch to using real colours for the internal representation, the user would not have this option. Should the user be have an option to choose the background colour by some other means?

If we would identify the amount of colors in the image and classify them into "quantified" colors (amount of quantified colors = amount of colors we want to knit with), we could show these colors to the user and let them choose which is the background color.

(What I mean by quantification: We would expect a coloured image to have only a certain amount of colors (as many colours as we want to knit with). But we could allow to load images with an arbitrary amount of colours. Rather, we do a quantification of the colors used in the image to boil down the amount of colors in the image to the amount specified by the user to knit with. e.g. this would handle colour deviation due to image compression.)

@t0mpr1c3
Copy link
Contributor Author

t0mpr1c3 commented Jun 7, 2020 via email

@t0mpr1c3
Copy link
Contributor Author

Pull request #313

Uses Image.quantize() to restrict the number of colours, Image.mode 'P' to represent colours, and frequency instead of lightness to determine the background colour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants