Skip to content

Instantly share code, notes, and snippets.

View nidhinp's full-sized avatar

Nidhin Pushpakaran nidhinp

View GitHub Profile
@nidhinp
nidhinp / make_bigger_image.py
Created August 9, 2019 10:20
make bigger image
def make_bigger_image():
""" To get a better result from OCR images should be large.
Function enlarges the image
"""
bolder_image = Image.open("bold_image.gif")
big = bolder_image.resize((1000, 500), Image.NEAREST)
big.save("bigger_image.tif")
if __name__ == "__main__":
image = Image.open("some_captcha_image_path")
make_bolder_image(image)
make_bigger_image()
final_image = Image.open("bigger_image.tif")
print(image_to_string(final_image))
<html>
<head>
<title>Graph</title>
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/style.css">
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
</head>
<body>
<center><h2>Graph Coloring</h2></center>
<center>
<canvas id="myCanvas" width="700" height="450" style="background-color: #ffffff; border: 5px solid #000000;">
var board = document.getElementById("myCanvas");
var ctx = board.getContext("2d");
var colorset = ['#698B22', '#CD2626', '#FF7F00', '#FFD700', '#00CDCD', '#1874CD', '#FF00FF', '#CD6090'];
$(document).ready(function(){
$("#vertex").click(function(){
tool = "vertex";
});
$("#edge").click(function(){
tool = "edge";
});
$("#clear").click(function(){
clears();
});
board.onmousedown = function(e) {
var x = e.pageX - this.offsetLeft;
var y = e.pageY - this.offsetTop;
ctx.fillStyle = "#000000"
ctx.beginPath();
ctx.arc(x, y, 10, 0 , 2 * Math.PI, false);
ctx.fill();
ctx.closePath();
ctx.fillText(++node_id, x+10, y-10);
node_set.push({id: node_id, "x": x, "y": y});
for (var i=0;i<node_set.length;i++){
var n_x = node_set[i].x;
var n_y = node_set[i].y;
if (!adj_list[i+1]){
adj_list[i+1] = [];
}
if (x <= n_x+10 && x >= n_x-10 && y <= n_y+10 && y >= n_y-10){
if (!edge_started){
s_x = n_x, s_y = n_y;
glitter(s_x, s_y);
function send(){
$.post("/", {adj_data: JSON.stringify(adj_list)}, function(data, status) {
colorify_graph(JSON.parse(data));
});
}
function colorify_graph (data){
for (var i=0; i<=node_set.length; i++){
ctx.fillStyle = colorset[data[i+1]];
ctx.beginPath();
function clears(){
document.location.href="/";
}
from django.conf.urls import patterns, include, url
from views import graph
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'graphs_django.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),