Another Sketch Challenge: T for Toucan
There is a lot of sketching challeng in the twitter asking the readers to draw/sketch something inspired by it.
I fond the @AnimalAlphabets there challenge this week is Toucan Bird.
So here is my sketch using pencil then black Pen and shading using black fine pin, it takes around 55min. More Sketches on my Sketch page ..
you may Follow me on Twitter @h_ta3kees
Here is my sketch..
Nikon S9900 shots – 5
Subject: Nikon S9900 Milk and Coffee
This Shot: I place my Milk Mug in the sun-light coming from a window, the camera on graound level and i took the shot using BW-color from the camera.
…Click Image to Enlarge… Camera in Hand, F:4 , ISO:160 , Shutter: 1/30s |
::.. To see all my Nikon S9900 Photos Click-Here
::.. To see all my Nikon D7100 Photos Click-Here
::.. To see all my Nikon D90 Photos Click-Here
By: Ali Radwani
Nikon S9900 Macro shot – 1
Subject: Nikon S9900 Macro shot
This Shot: A Macto-Shot on Fruit, using Nikon S9900.
Camera in Hand, F:4.2, ISO:125, Shutter:1/4s
Camera in Hand, F:4.2, ISO:125, Shutter:1/4s |
By: Ali Radwani
Python: Random Pixel Color – P2
Learning : Python, Math
Subject: Random Coloring Pixels
[NOTE: To keep the code as simple as we can, We WILL NOT ADD any user input Varevecations. Assuming that our user will Enter the right inputs.]
Our last post about Random Pixel Color, we generate a Numpy Array of Row, Coloum and color then we Plot it on the screen [Read the Post Here], now in this post we will use some Math consepts to try if we can get some patterns out of ramdom Function.
Our Tools: In this post we will use the following:
1. Jupyter-NoteBook.
2. numpy.
3. random.
4. matplotlib.
5. PIL or Pillow.
In this version we will use “Fibonacci Sequence” Fibonacci Sequence is the sum of the two preceding ones, starting from 0 and 1 such as [1, 1, 2, 3, 5, 8, 13 … n], in our code we will have three variables:
cw: canvas width,
ch: canvas hight,
offset: the offset will be the value that will reset the Fibonacci Sequence to 1.
So, if we run the application, we will generate three numbers that will present the colors R,G,B (Will be Generated ONE time) then for each pixcel in (cw*ch) we will calculate a v as Fibonacci Sequence from fs1 =1, fs2 = 1 here is the code:
v = fs1 + fs2
fs1,fs2 = fs2, v
this value v will be added to the colors r,g,b (on each pixcel) untill the v is grater the the offset numbre that we pass to the Function. If v > offset then we will re-set the fs1 = 1, fs2 = 1,.. Here is the Code ..
Run No.1 | Run No.2 |
Run No.3 |
Run No.4 |
The above is just 25×25 and i change the offset, feel free to download the code and change the numbers .. see what you will get …
..:: Have Fun with Coding ::.. 🙂
To Download my Python code (.py) files Click-Here
By: Ali Radwani
Another Sketch Challenge: wood store
This week sketch challenge @1hour1sketch on Twitter is to Draw maybe a small Wood Store House so here is my sketch using pencil then black Pen, it takes around 15min. More Sketches on my Sketch page ..
you may Follow me on Twitter @h_ta3kees
Here is my sketch..
Python: Random Pixel Color
Learning : Python, Math
Subject: Random Coloring Pixels
[NOTE: To keep the code as simple as we can, We WILL NOT ADD any user input Varevecations. Assuming that our user will Enter the right inputs.]
Last week I start reading and studying about “Image Processing”, in some point I was reading about converting an image to Array of numbers, and re-converting that Array back to an Image, at that moment popped into my mind what if we just generate an Array with random numbers and then show it as an Image.
In this article we will write a first simple Function to generate a random numbers presenting the three main color Red, Blue and Green; then storing the numbers in an Array then using matplotlib library to display the Image.
Our Tools: In this post we will use the following:
1. Jupyter-NoteBook.
2. numpy.
3. random.
4. matplotlib.
5. PIL or Pillow.
Coding I am user Jupyter NoteBook on samsung Tab S4. First we will do all imports we need as:
from PIL import Image
import numpy as np, matplotlib.pyplot as plt
import random
%matplotlib inline
Now, we will write a Function called rand_color, we will run a nested for loop to generate the Row and Column (width and height) and in/for each row we will generate thee numbers of colors range(0,255) as one pixel and storing them in an array, then we display the Array using:
Image.fromarray and plt.imshow(). Here is the Code ..
Run No.1 |
Run No.2 |
Run No.3 |
Run No.4 |
The above is just 25×25 image with random color pixels, this is the first function using default random, in coming posts we will use some Math variables [such: log,sin], constants [such: pi, golden ratio] to see if we can get a pattern from random.
..:: Have Fun with Coding ::.. 🙂
To Download my Python code (.py) files Click-Here
By: Ali Radwani
Python Sorting Algorithm – Heap Sorting -P5
Learning : Python, Math, Algorithm
Subject: Sorting Algorithm, Heap Sort P5
[NOTE: To keep the code as simple as we can, We WILL NOT ADD any user input Varevecations. Assuming that our user will Enter the right inputs.]
In Last Parts (2, 3 and 4) we wort the Following Functions:
- Sections Header.
- Main Menu Function.
- Entering/Creating the Array.
- Print-Out or to Display the Array.
- Check If Array in Max-Heap.
- Convert Array to Max-Heap.
- Add Node to Max-Heap.
- Delete a Node from a Max-Heap.
In this last part-5 we will write the last main Function to aplay the Heap Sorting Algorithm.
Scope of Work: Deleting a Node from a Max-Heap Array is the main function in sorting an Array using Max-Heap Algorithm, the Deleting is always from the Root Node, So if we delete the most top Node [Root] (and store it in index[0] in a temp_array) then we move the Last Node to it’s position and by doing that we miss the Max-Heap state of the Array, so we convert the array to a Max-heap, then we Delete the Root again until we delete all the elements in the Array.. Here the Algorithm:
Assuming we have a Max-Heap Array:
1. Delete the Root Element, and Store it in index[0] in Temp_array.
2. Move the Last Element in the Array to index[0].
3. If the Array not in Max-Heap then Convert it to a Max-Heap.
4. Repeat Steps 1 to 3 Until length of Array is 0.
In our list of Functions up, we have the three Functions we Need to complete/apply a Max-Heap Sorting:
We Delete a Node using def delete_node(arr,inside):
then in a while loop we call both
def check_if_max_heap (arr,inside): and
def convert_to_max_heap (arr,inside): so let’s see the code..
We finish Max-Heap Sorting Algorithm, ..
..:: Have Fun with Coding ::.. 🙂
To Download my Python code (.py) files Click-Here
By: Ali Radwani
Python Sorting Algorithm – Heap Sorting -P4
Learning : Python, Math, Algorithm
Subject: Sorting Algorithm, Heap Sort P2
[NOTE: To keep the code as simple as we can, We WILL NOT ADD any user input Varevecations. Assuming that our user will Enter the right inputs.]
In Last Parts (2 & 3) we wort the Following Functions:
- Sections Header.
- Main Menu Function.
- Entering/Creating the Array.
- Print-Out or to Display the Array.
- Check If Array in Max-Heap.
- Convert Array to Max-Heap.
In this Part-4 we will cover another Two important Functions that we need to talk about in our mission to understand the Heap Sorting Algorithm. In a Max-Heap Array we may need to Add new Node to the Array and we may need to Delete a Node. Also I just add Item No.7 style=”color:#2662ee;”>print(‘ ‘*5,’ 7. Start Heap Sorting.’) to the main-menu so we can do Heap Sorting to a given Array.
Starting with Add New Node, Simply we Add the Node to the end of the Array using arrat.append(new_node) then we need to Check If still the Array in Max-Heap If NOT, We MUST Convert it to a Max-Heap.
Scope of Work Ask the user to Enter the New Node Value, Add The Node to the End of the Array, in While Loop Call convert_to_max_heap (arr,True), check_if_max_heap (arr,True) as following:
while not is_max:
arr = convert_to_max_heap (arr,True)
is_max = check_if_max_heap (arr,True)
this will keep check and convert the Array to Max-Heap. Here is the Full code and run screen ..
Now we will write a Function to Delete a Node from the Max-Heap Array. Deleting a Node is just by removing the first node in the Array (Array[0]), then moving the last element in the Array to it’s position, by doing this we may not having a Max-Heap Array any-more, so we need to convert the array to a Max-Heap. In our application here, we will have a while loop and calling the functions (check_if_max_heap and convert_to_max_heap) until we have the Array in a Max-Heap. Here is the code ..
We will stop here in this part. In Part-5 we will Sort any Array using the Max-Heap Sort Algorithm.
..:: Have Fun with Coding ::.. 🙂
To Download my Python code (.py) files Click-Here
By: Ali Radwani
Sketch: Crane Bird Landing
Here is another sketch using pencil & black ink pen to sketch a Crane Bird Landing on the shores of a Lake. I am sketching to improve my skill .. 🙂
By: Ali..
Follow me on Twitter: @h_ta3kees
Python Sorting Algorithm – Heap Sorting -P3
Learning : Python, Math, Algorithm
Subject: Sorting Algorithm, Heap Sort P2
[NOTE: To keep the code as simple as we can, We WILL NOT ADD any user input Varevecations. Assuming that our user will Enter the right inputs.]
First let’s just remember that in Part-1 we wort the Following Functions:
- Main Menu Function.
- Entering/Creating the Array.
- Print-Out or to Display the Array.
- Sections Header.
In this Part-3 we will cover another Two important Functions that we need to talk about in our mission to understand the Heap Sorting Algorithm.
First Function
Check If The Array is in Max Heap: After the user Giveing/Entering the Array [Selecting Option 1 in the Menu] we need to Examen/Check if it is in a Max-Heap, to do so we will call the Function def check_if_max_heap(arr, inside): the Function will take Two arguments:
arr : The Array.
inside: Boolean Flag showing are we calling the Function from within another Function or Not.
Scope of Work: We will check and compare each Node [starting from last node in the leaves] with it’s Parent using this formula parent_index = ((child_index-1)//2) to get the parent index, then comparing the Values of the Child and Parent, If the Child is GRATER Than his Parent we SWAP them. Then going to the Next Child and so-on until the Root-Node. .. Here is the Code ..
for each print statement I am using this code if not inside : then print ..
Example: if not inside : print(‘\n The Array is a Max-Heap Array.’)
So if the inside = True then the print code will not work, that’s mean we are calling the Function from inside another function and we just want the return value, the return here will be a boolean True/False as is_max [if the array is in Max-Heap].
Second Function
Convert to Max-Heap: In this Function we will convert a given Array to a Max-Heap Array. The way this Function is working is by checking/Examining all the Childs starting from the Leaves, and if any Child is Grater than his Parent we do a SWAP. After we Finish, we will call the Function def check_if_max_heap(arr, inside): to check if the Array is in Max-Heap, If NOT we will call the convert Function and so-on until we get the is_max = True from the def check_if_max_heap(arr, inside):. Both Functions def check_if_max_heap(arr, inside): and def convert_to_max_heap (arr,inside): will be run in a while loop until def check_if_max_heap(arr, inside): will return True. .. Here is the code for def convert_to_max_heap (arr,inside):
And here is the while loop to keep Examining the Array until fully converted to a Max-Heap Array.
# While loop in Option 3 from the Main-Menu, In the main body code.. while not is_max: arr = convert_to_max_heap (arr,True) is_max = check_if_max_heap (arr,True)
We will stop here in this part. In Part-4 we will Add new Node to the Array, and Delete a Node from the Array.
..:: Have Fun with Coding ::.. 🙂
To Download my Python code (.py) files Click-Here
By: Ali Radwani