Skip to content

Instantly share code, notes, and snippets.

View muthuspark's full-sized avatar

Muthukrishnan muthuspark

View GitHub Profile
from skimage import color
from skimage.io import imsave
lab_img = color.rgb2lab(cimage)
copy_img = np.copy(cimage)
L_img = lab_img[:, :, 0]
A_img = lab_img[:, :, 1]
B_img = lab_img[:, :, 2]
# green a > -35
from skimage import color
from skimage.io import imsave
lab_img = color.rgb2lab(cimage)
copy_img = np.copy(cimage)
L_img = lab_img[:, :, 0]
A_img = lab_img[:, :, 1]
B_img = lab_img[:, :, 2]
x,y,z = lab_img.shape
for xi in range(x):
 for yi in range(y):
@muthuspark
muthuspark / scrollTo.js
Created June 26, 2020 12:47
Pure Javascript implementation to Scroll to a particular element on page.
// the code will also try to center the element on the page.
var ElementScrollTo = {
documentVerticalScrollPosition: function() {
if (self.pageYOffset) return self.pageYOffset; // Firefox, Chrome, Opera, Safari.
if (document.documentElement && document.documentElement.scrollTop) return document.documentElement.scrollTop; // Internet Explorer 6 (standards mode).
if (document.body.scrollTop) return document.body.scrollTop; // Internet Explorer 6, 7 and 8.
return 0; // None of the above.
},
viewportHeight: function() {
@muthuspark
muthuspark / Get APK of playstore app through abd
Created September 18, 2019 10:07
series of steps to get the apk from the phone in usb debugging mode.
The sequence of steps lets me download an APK of any app I have downloaded from the playstore.
1. install the app from playstore in the app or emulator. example instagram
2. get the name of the package of the app I am interested in, this can also be taken from the playstore URL,
``adb shell pm list packages | grep instagram``
3. get the location of the apk in the phone
``adb shell pm path com.instagram.android``
4. download the app to the local system
``adb pull /data/app/com.instagram.android-XJc0EbhiBn-d0G4UmdnmgQ==/base.apk``
@muthuspark
muthuspark / gist:442bd75f3dae4e73c8b2bbe0edba48d8
Created June 26, 2019 01:28
convert a dictionary to array in python
# A list of the keys of dictionary
list_keys = [ k for k in dict ]
# or a list of the values
list_values = [ v for v in dict.values() ]
# or just a list of the list of key value pairs
list_key_value = [ [k,v] for k, v in dict.items() ]
@muthuspark
muthuspark / gist:25ebe61b11617f86668655326ea3a82d
Created May 10, 2019 16:44
run length smoothing algorithm - on binary image
X = [0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,1,0,1,1,1,1,0,0,0,1,1,1,0,0,0,0,1]
def run_length_smoothing(X, run_length_width):
block = []
for index, intensity in enumerate(X):
if intensity == 1 and len(block) <= run_length_width:
for j in block:
X[j] = 1
@muthuspark
muthuspark / gist:d1c0d567ac295a796b011a5d0fb33b4c
Created May 10, 2019 16:41
upload image from local file - python request
import os
import requests
img_to_upload = '/Users/muthukrishnan/Pictures/15566790261881556159500299IMG_20190330_120119.jpg'
url = "http://localhost:5000/api/document/page-extract"
uploaded_img_path = ''
with open(img_to_upload, 'rb') as img:
name_img = os.path.basename(img_to_upload)
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.datasets.samples_generator import make_blobs
class K_Means:
def __init__(self, k=3, max_iterations = 500):
self.k = k
@muthuspark
muthuspark / gist:f43b08251cd0ec813dfd75823a644fff
Created February 27, 2018 13:18
List all the files in AWS bucket nodejs
var AWS = require('aws-sdk');
AWS.config.update({
accessKeyId: "ACCESS_KEY",
secretAccessKey: "SECRET_ACCESS_KEY"
});
// Create an S3 client
var s3 = new AWS.S3();
@muthuspark
muthuspark / gist:5949e24fe19feb0c363677385185538a
Created September 1, 2017 10:07
Node JS based code to upload folders into AWS S3 using aws-sdk
var q = require('q');
var AWS = require('aws-sdk');
AWS.config.update({
accessKeyId: "131231",
secretAccessKey: "23135124"
});
// Create an S3 client
var s3 = new AWS.S3();