You can reduce the file size of an image by
Removing the number of bits you need to represent
Each the colors and if you remove that number of bits
You have less colors, you can display so the image looks worse
If you've got eight bits, you've got 256 levels of gray or levels of each color if you've got four bits
You've only got sixteen if you've got one bit you've either got black or white
and so what did ring is it's doing is an attempt to
Simulate those extra gray scales. Let's keep it to a gray scales for the purpose of this video
Just using black and white pixels or whatever colors you've got on the end for this video
We'll just keep it to either having a black or a white pixel
So quite often computers certainly early screens or even these days with printing they can either display a
Pixel or they can't display it they can either be black or it can be white
Let's take this to the extreme because it basically is the same even if you have got more colors
Let's assume that we've got a display that can either display a black pixel or a white pixel. It might be a printer
It might be a sort of very very simple video display of some sort particularly thought you find on sale
an early 80s computer something although might be black and green then but let's go black and white and what we want to do is
to be able to display which is that a
continuous tone
So they they don't just have black or white we go from black through grays to white and again
You could extrapolate this out to different colors. And so you need some way of mapping the grays
Into black and white a naive way we could do this. We've got an image. Let's say it's a photograph
I say it's this video
I'm sure I'll apply the special effects to make it look this and we need to convert it to black and white as we can
Say anything
Below a certain level will make black anything above a certain level will make white so we can do that and if you do that
You can pick the level of which you make that switch you get it with an effect like this
where you can sort of see it Steve but
realistically, you've got lots of white and lots of black that call for a special effect, but not
Useful for watching or printing things. So that's a naive approach
It's actually a problem that's existed for
Years newspapers are printing in general as had this problems pretty much since photography was invented in the 8th
Hundreds and the way they get round it is that they convert the image into a series of dots actually this was originally done
optically the image that they wanted to print was put in front of a camera and a screen was put in front of it of
Lots and lots of small things and it was rephotographed with very high contrast
and what happened was whether
Holes in the screen were you've got very small pin pricks of light that depending on how bright they were made bigger or smaller
discs on the
Photographic plate and that's what was printed. So we need to do the same thing
On our computer one way to look at it if we wanted to say make this square
Gray, if you wanted to make it black, then we could just color in all the pixels
So can you have it as white or black but we can also make it
Appear grey just like the newspaper did by not coloring all the squares inside we can make it appear
gray by coloring in this one and then coloring in
This one like this and if you do that and you do that for enough of them next to each other
If you zoomed out from that then it would look about 50% gray
you could do a lighter gray by just setting one pixel of those four in each one and
Just to finish off we could create a darker gray
by
filling in all
But one of the pixels we can create just with a 2x2 grid of pixels a white one a black one
50% gray probably around 25% gray and around 75% greater and get 1 2 3 4 5
Different levels of grey just by using a 2x2 grid and selectively coloring in the pixels
what's actually happening is that your eye is at acting like a sort of optical low-pass filter and
When it's slightly fine of a way you stop seeing the individual pixels and you just see the sort of average gray from the number
Of things that are in there you sort of converting the high frequency off the norms of the image into a grayscale
Because you're looking at from a distance and so on
So that's what did the ring effectively is. It's choosing a pattern of white and black dots to create
The image to create the grey or to simulate the gray that was a better way of saying it now
How do we do that in a computer now if we think about an image the image if we've sampled it?
It's broken up into pixels and then they have a number associated with it to say how bright the artless is. Zero is black
255 is fully white. So what we could do is say well, let's say they're 50% gray. They said they're all 50% gray
So let's say this is 128
This is 128. That's 128. That's 128 and so on
So how do I programmatically convert that grid which is 50% gray
Into the grid
I've got here
Where I say? Okay, I want that one on I want that one off
I want that one on I want that one off so we could do it by patter matter
We could look at this and say okay these four pixels here or 128 therefore
we need to draw that pattern in it and these for
64 every 25% gray so we'll draw that pattern the pixels in it
You could do like that, but it's actually a clever way. You can actually do this
Let's draw out a grid of the 4 by 4 here
so what I'm going to do is I'm going to say if this
pixel is greater than 0 I will set it if the value in the pixel is greater than
64 I will set that pixel if it is greater
Than 1 to 8
I will set that pixel and if it is greater than 1 9 2 I will set that pixel
Okay, so these are each of our indifferent your pixels. So go back to my pixels here and I start
With this one is 128 greater than 64. Yes, right so we color that in we're at my level again here in math. Yes
We now move on to the next pixel is 128 greater than hundred 28
No note that we leave that there is 128
Greater than that form all there isn't a next one. So we go back to the beginning
greater than 64
Yes, we set that again. And now we're going across here is 128 greater than hundred twenty-eight. No, so we leave that blank
So now we come down onto line two and we do the same thing with the second line here is 128 great at 192
No, right. Ok, we leave it is
Twenty-eight greater than zero. Yes. Okay, so we get the program to set this pixel here
Is it greater than hundred ninety-two? Nope, is it greater than zero? Yes
and so we set that one there like that and
We're back here. And we do the same thing as a greater than twenty eight and
Then no yes
No
No, yes
No, and what happens is that you end up creating the pattern we'd come up here before?
Just by applying that
Thing there. Okay. Let's try that again and we'll do it a bit quicker this time. Let's say that these are all 24
So what happens? Well, we do exactly the same thing. We apply this is 24 great in 64
No is 24 greater than hundred twenty-eight. No is 24 great in 64. No, it's 24 greater than hundred twenty-eight
No is 24 greater than 192? No is 24 greater than zero. Yes
So we fill that in is 24 greater than hundred ninety-two. No zero. Yes, and now I shall go the same faster drew
No, no, no. No. Yes. No. No, yes
And someone created the pattern that we had
For the library a case come up in a different position in that we had it in the top left
But let's come in here. That was like any difference to how it would look to art. It's just where the dots are
Positioned and you say we've got something that we can now apply
Programmatically to create these five different patterns to the image that we can take our image
Run that overage and create the same thing we get a nice fine
Series of dots for the problem with this is that we've only got five different colors black dark gray mid gray light gray
White why don't we wanted more colors?
Well the way we could do that is make this matrix bigger and use a number of things
But the problem with that is if we do that we have to trade off the resolution of our image
Because the dots will become bigger
to illustrate that
You're going to jump away from the paper to my laptop because why I've done I have created a little video
Which takes the image from white to black. So if we play it this is gray scales that goes from white
two black over the course of ten seconds
255 or 256 frames are then exported this as a target image sequence relative poem which applies the same algorithm
But this time using an 8x8 grid and because I did it at low resolution
We can actually see the dots and so on. So if we play the same video this time, it's halftone
We can see that the way it's doing it is that the dots they're getting bigger and bigger until eventually
you end up with a completely black screen, but
whereas before
When we got to 50% gray
We had relatively small pixels. There was one pixel arm one pixel off
We've now got four pixels on four pixels off and bigger squares. So we've got dots that we can see
just like the
dots in the newspaper, we can actually start to see the individual dots but we still get that effect as if
They're getting the images getting darker as we go through it
And in fact if Shawn were to sort of point is camera at it that should if you gets it out of focus
You know if the camera will act as a low-pass filter and you should see it go from like white to dark gray
But it is still a collection of dots next to each other
So that's one way that we can dither an image
We can sort of apply a regular pattern and ordered patterns as an order. Did they recall this to the image? And
Convert the individual pixels
Into black and white dots to create the gray scales
We can either say it to be white
255 or black zero so we choose the one which is closer
So in this case the closest one we could leave it as white
255