Skip to content

Instantly share code, notes, and snippets.

@anilsathyan7
anilsathyan7 / README.md
Last active October 24, 2019 08:23
Cluster similar patches in an image using ssim, with the help of opencv and scikit-learn

Sample Output

Similar patches or objects in the input image(left) are grouped into same clusters, using Structural Similarity Index(SSIM). Members of the same cluster are shown with same coloured bounding boxes in the output image(right).

@anilsathyan7
anilsathyan7 / README.md
Last active October 24, 2019 08:27
Cluster similar shapes in an image using hu moments, with the help of opencv and scikit-learn

Sample Output

Similar shapes in the input image(left) are grouped into same clusters, using hu moments. Members of the same cluster are shown with same coloured bounding boxes in the output image(right).

@anilsathyan7
anilsathyan7 / image_scramble.py
Last active August 6, 2019 10:56
Scramble-Unscramble - Shuffles images into fixed size patches to create a jigsaw puzzle.A key-map dictionary is used to recover the shuffled image.
import numpy as np
from PIL import Image
from imageio import imsave
from skimage.util.shape import view_as_blocks
# Global shuffle key
map={}
'''
Args:-
@anilsathyan7
anilsathyan7 / convert_to_numpy.py
Last active December 31, 2023 05:11
Convert all images in a directory to ".npy" format
from PIL import Image
import os, sys
import cv2
import numpy as np
'''
Converts all images in a directory to '.npy' format.
Use np.save and np.load to save and load the images.
Use it for training your neural networks in ML/DL projects.
'''
@anilsathyan7
anilsathyan7 / synthetic.py
Last active July 14, 2019 18:04
Synthetic image composting as data-augmentation for semantic segmentation datasets
from PIL import Image
import os, sys
from scipy.misc import imsave
import cv2
import numpy as np
import random
import argparse
'''
Creates synthetic images with custom backgrounds, using the default images and masks in the dataset.
@anilsathyan7
anilsathyan7 / image_capture.py
Created May 4, 2018 21:21
A program in python for capturing images from webcam, using OpenCV
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
i=1
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
# Operations on the frame
@anilsathyan7
anilsathyan7 / colour_cv.py
Created May 4, 2018 19:22
Image classification with Caffe, OpenCV and Digits on JetsonTX2 using Deep Learning
import caffe
import numpy as np
import cv2
import Image
import os
#nvcamerasrc
#gst = "/dev/video1 ! video/x-raw(memory:NVMM), width=(int)640, height=(int)480, format=(string)I420, framerate=(fraction)30/1 ! nvvidconv flip-method=0 ! video/x-raw, format=(string)I420 ! videoconvert ! video/x-raw, format=(string)BGR ! appsink"
#gst-launch-1.0 v4l2src device="/dev/video1" ! 'video/x-raw(memory:NVMM), width=(int)640, height=(int)480, format=(string)I420, framerate=(fraction)30/1' ! nvvidconv flip-method=0 ! 'video/x-raw, format=(string)I420' ! videoconvert ! 'video/x-raw, format=(string)BGR' ! fakesink
@anilsathyan7
anilsathyan7 / shellscript.sh
Created July 31, 2017 16:00
A sample shell-script code
clear
echo -e "\e[1;4mI LOVE SHELL SCRIPTING!!\n"
echo -e "WELCOME \033[31m$USER to $HOSTNAME"
$ echo -e "\033[7m Linux OS! Best OS!! \033[0m"
echo "Today is `date`"
val=`expr 6 + 3`
echo "six plus three is $val"
echo "What is your full name?"
read fname
echo "Hello $fname, my buddy!"
@anilsathyan7
anilsathyan7 / index.html
Created July 31, 2017 15:52
Google Real-time API Sample Code from google developers (https://developers.google.com/google-apps/realtime/realtime-quickstart)
<!DOCTYPE html>
<html>
<head>
<title>Google Realtime Quickstart</title>
<!-- Load Styles -->
<link href="https://www.gstatic.com/realtime/quickstart-styles.css" rel="stylesheet" type="text/css"/>
<!-- Load the Realtime JavaScript library -->
<script src="https://apis.google.com/js/api.js"></script>
@anilsathyan7
anilsathyan7 / first.tcl
Created July 31, 2017 15:38
Tcl demo code
# The preamble
 
set ns [new Simulator]                                                               ;#initialise the simulation
 
# Predefine tracing
set f [open out.tr w]
$ns trace-all $f
set nf [open out.nam w]
$ns namtrace-all $nf