A simple CLI application to do some image processing tasks
Clone the repository using
git clone https://github.com/JosiasAurel/mirage.git
Now go to the project root
cd mirage
Install packages with cargo build
.
Create a release build with cargo build --release
.
You should then have a binary called mirage
in /target/release
.
Run the binary by calling it ./mirage
.
infile.png and outfile.png represent the input image file and the name of the output file, respectively The extension (.png) could be any other extension like .jpeg, .jpg etc
You can blur images by running
./mirage blur input.png output.png
The default blur amount is 2.0 but you can change that to any amout you want by passing a number as third argument.
./mirage input.png output.png 3.4
Make an image grayscale by running
./mirage grayscale input.png output.png
Invert an image using
./mirage invert input.png output.png
You can rotate an image left
or right
or make it reverse
.
./mirage rotate input.png output.png left|right|reverse
This will brighten the image by an amout of 2
./mirage brighten input.png output.png
Set your own brightness by passing a number as third argument. It should be an integer. Negative values will make the image dimmer while positive values will make it brighter.
./mirage brighten input.png output.png 4
Run
./mirage crop input.png output.png x y width height
Where x and y represent the initial points where to crop while width is how much to move on the x-axis and height is how much it moves from the y-axis. These arguments are required.
The CLI will generate a Julia set fractal if you run
./mirage fractal outfile.png
The CLI can also generate random beautiful patterns if you're lucky.
./mirage generate outfile.png
Some sample patterns below
Polar Coordinates 👩🎤 ... no, there are no polar bears.
I'll save you some brain cells and direct your to Brilliant if you want to understand them.
I will assume you have gone through the article and have an understanding on how to plot polar curves
Generally polar coordinates are of the form
We know that
Note : If you are unsure about x and y, think of Pythagorean theorem.
This alone proves our first equation.
In polar coordinates, points are of the form
In order to plot each polar point,we need to first convert them to cartesian points.
For
If you take a look at the code, I could easily loop within a range of values, get the (x, y) values and drop them on the image. But that means we might have to do two loops.
- One for plotting the polar points (converted to cartesian points)
- Another to light all the other pixels
That's double work... let's save time and resources
So a simpler method would be to just iterate over the pixels of the image and light the ones that fall on the polar curve with a special color to differentiate them.
Okay? How do we do that?
Glad you asked!
First we know we can get the value of
We can simple substitute
This same operation is repeated for each (x, y) value of the image until we are done. The final output is a beautiful pattern.
Contributions & Improvements are welcome.