Skip to content

Instantly share code, notes, and snippets.

#change image to thumbnail
#but not change width and height aspect ratio
#read image and convert grayscal
from PIL import Image
pil_im = Image.open('./data/empire.jpg').convert('L')
pil_im.thumbnail((200,200))
pil_im.show()
from PIL import Image
pil_im = Image.open('./data/empire.jpg').convert('L')
#be careful it may change aspect ratio
out = pil_im.resize((128,128))
#show
out.show()
from PIL import Image
pil_im = Image.open('./data/empire.jpg').convert('L')
#rotate clockwise
out = pil_im.rotate(45)
#show
out.show()
# convert image to numpy array
im = array(Image.open('./data/empire.jpg')) #return numpy array
# show
imshow(im, interpolation='nearest')#or interpolation='None'
# star point
x = [100,100,400,400]
y = [200,500,200,500]
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script type="text/javascript">
var globalTestItemNo = 1;
var TESTITEMNUM;
var DIVIDEDIMGNUM;
function globalTestItemNo2testName(globalTestItemNo){
(defun my-open-new-memo ()
(interactive)
(let ((my-regexp "\\([0-9]+\\)[.]memo")
(my-max 1)
(my-matched-num 0)
(file-list (directory-files "~/.emacs.d/memo/")))
(dolist (i file-list)
(setq my-matched-num (string-to-number (replace-regexp-in-string my-regexp "\\1" i)))
(if (< my-max my-matched-num)
(setq my-max my-matched-num)))
from PySide.QtGui import QApplication, QMainWindow, QAction, QActionGroup, QWidget, QCursor, QPainter
from PySide.QtCore import QTimer
import PySide.QtCore as QtCore
class W(QWidget):
def __init__(self):
QWidget.__init__(self)
self.resize(400,400)
self.myIsMousePressing = False
self.p = QPainter(self)
from PySide.QtGui import *
from PySide.QtCore import QTimer
app = QApplication([])
widget = QWidget()
textbox = QLineEdit()
startbutton = QPushButton("start/stop")
resetbutton = QPushButton("reset")
timelabel = QLabel("00:00:00")
counttimer = QTimer()
hboxlayout = QHBoxLayout()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#This software is released under the MIT License, see below.
#----------------License----------------
#The MIT License (MIT)
#
#Copyright (c) <2015> <Kei Minagawa>
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
import os
from glob import glob
import cv2
import numpy as np
from numpy import arange
import matplotlib.pyplot as plt
from matplotlib.figure import Figure
from matplotlib.backend_bases import key_press_handler