Posts

Showing posts with the label python

Image Cropping and Scaling Algorithm using linear algebra

THE SCENARIO : I had to formulate an algorithm to convert an image of some resolution - say L x M and crop / re-size the image into a new resolution say P x R such that I cover the maximum amount  of points/pixels from the original image . APPLICATION : This can be pretty much applied in a generic way to all programs and websites in need of an optimized algorithm to rescale / reduce the size of the original image in their application such as profile images in social networks etc. THE APPROACH : To cover the maximum amount of pixels from the original image we have to focus on cropping the image to the target aspect ratio first and then re-scaling it to the new resolution. Hence, the problem comes down to achieving the target aspect ratio that would help me capture the maximum amount of pixels of the original image so that I end up with an image which is pretty close to what the original image should have been in the new resolution. DETAILS : The sig...

Python-C-Extension

Skeletal code to create exposed C, C++ Extensions for Python Just wrote some generic handy code which I thought I'd upload. Performance boost of using C, C++ extensions in some operations is quite significant and proven. Use this code to add pre-written C, C++ code and build it in a way that it's functions are exposed as python packages. The code has been hosted on github HERE . Build to a shared object to access the c library as a python package. usage: > import helloworld >helloworld.printhelloworld() Θ Ω Sushant ♂

ClamAV - One of the 'good' open source command line antivirus solution

This really makes my life easy if I want to deploy an upload server, or a mail server in UNIX and the files would be downloaded in WINDOWS or similar virus-prone operating systems. You can read more about it on the official website . A C-extension for python is available HERE to programmatically scan files and open pyclamd (daemon) socket. Θ Ω Sushant ♂

Key points of difference between "C#/Java" and Python

1. Indentation. 2. Dynamically typed python 3. for-else loop 4. mutable lists 5. syntax of almost everything : - functions : def keyword Θ Ω Sushant ♂