Python: PIL (Pillow) & Numpy intersect images


Input images used :

1.png C.png

Continue reading Python: PIL (Pillow) & Numpy intersect images

Python: PIL ( Pillow ) & NumPy add images


Pillow (PIL) and NumPy libraries can do wonders in Python! I had once he requirement to overlap two images – not watermarking.

I found several alternatives, but curious to see which would work best.

  1. (x+y)/2 … Mathematically, x/2+y/2 seems equivalent to above, but it is not. We’d be loosing a ton of info by doing so!
  2. Numpy.minimum((x+y),256)
  3. final = (x+y/2) and then addition = addition[addition>256]=256
  4. Pillow’s Image.blend(x,y,0.5)
  5. Pillow’s Image.composite(x,y,y)

Continue reading Python: PIL ( Pillow ) & NumPy add images

Python: find most common element from list of lists


I took a swing at answering a question on StackOverflow, albeit I liked the accepted answer better than mine. But Continue reading Python: find most common element from list of lists

Python : sort int list based on another


This post discusses how to custom sort one list in python based on the order of elements of another list.

Continue reading Python : sort int list based on another

Python: Find closest from given dictionary values


Objective: I have a dictionary, and a float value. I would like to sort the dictionary in such a way that, first key-value pair’s value is nearest (min absolute difference) to a given float value, and last would be the farthest (max absolute difference)

Python: Compare Dictionaries


Getting Started: Python


I personally think that Visual Studio is the best IDE, and I spend most of my day in it. And I’d definitely by using Visual Studio as much as I can –  if you are on Windows, Visual Studio’s Python support is worth exploring.

I’d leave the choice up to you. Both IDE have free and paid options.

I think Visual Studio is an engineering marvel. If as much effort went into space travel as went into the design of this, we’d be on Mars by now.

That said if you  prefer to use PyCharm:

  • Please go to https://www.jetbrains.com/student/ and get your free full blown tools offered by Jet Brains, with all bells and whistles.
  • Here are two YouTube video series if you want:

Getting Started with PyCharm:

PyCharm Video Demos:

 

 

 

 

If you want to use Visual Studio: