I added another feature to the web application. This is opencv's face detection application - just upload an image and see the magic! (click here to go to the application)
Tuesday, November 24, 2009
Thursday, September 24, 2009
Image filtering, smoothing, canny edges
So here is the result of the last post - The current functionality of the application is filtering an image with a given filter and two specific filters - blurring and canny edge detector. Scroll to the right to see the resulting image (or just click here to go to the application)
Monday, September 7, 2009
Image Processing Web Application
I started recently getting into building web applications. Here is a beginner's experience with the issues involved:
My idea was to build some front-end for opencv so people from all around the web could play around with the functionality easily. The current state of my experimentation can be viewed here.
It doesn't use Opencv yet(I'm using ImageMAgick), for reasons I shall explain below.
Here's a list of things you need to set up for such an application:
Up to this point I am extremely pleased with BlueHost. They are perfect as a cheap, shared hosting environment. They support Ruby on Rails, they have loads of documentation, and they have an online live customer support. Their administrator panel (the gui you use to manage you hosting stuff) is very user friendly and load without problem.
The only problem I have with them is the Python support which is rather minimal so I could not get opencv installed properly on their server. So for my experiment I used Rmagick which is a Ruby wrapper for ImageMagick and getting that up and running was rather straight forward without much complications.
My next step would be to get familiar with Django, which is the web application framework for Python, and find a hosting service which supports it (recommendations are welcome). Then continue with my original plan of doing something with Opencv.
My idea was to build some front-end for opencv so people from all around the web could play around with the functionality easily. The current state of my experimentation can be viewed here.
It doesn't use Opencv yet(I'm using ImageMAgick), for reasons I shall explain below.
Here's a list of things you need to set up for such an application:
- A domain - typically these would cost at around 10$ for ordinary domains, I got mine from GoDaddy but there are endless places where you can do it.
- What web application framework you want to use. As I see it the decision should be based on which programming language you feel most comfortable with. Languages like Java, Ruby, Python each have their own framework (I;m familiar with Ruby on rails and recently got introduced to Django for Python).
- Hosting environment.When deciding where your application is going to run you should consider the following:
- What web application framework you are using. You should check that the hosting environment has full support for your framework - this includes looking for reviews and hearing what other people say and not just what the hosting provider says
- What are your computational and network load requirements. As a beginner I use shared hosting which is the cheapest (costs at around 100$/year) since I am not really sure about those issues yet. This means your server is shared with other users. The more expensive option is to have a dedicated server or use a cloud in which resources are dynamically allocated as needed by the application.
- The customer support offered by the hosting provider. Again, look around the web for reviews.
- Price
Up to this point I am extremely pleased with BlueHost. They are perfect as a cheap, shared hosting environment. They support Ruby on Rails, they have loads of documentation, and they have an online live customer support. Their administrator panel (the gui you use to manage you hosting stuff) is very user friendly and load without problem.
The only problem I have with them is the Python support which is rather minimal so I could not get opencv installed properly on their server. So for my experiment I used Rmagick which is a Ruby wrapper for ImageMagick and getting that up and running was rather straight forward without much complications.
My next step would be to get familiar with Django, which is the web application framework for Python, and find a hosting service which supports it (recommendations are welcome). Then continue with my original plan of doing something with Opencv.
Labels:
bluehost,
django,
godaddy,
hosting,
image processing,
Imagemagick,
rails,
web application
Thursday, May 7, 2009
Generate a thumbnail of a web page
I found this usefull page which describes how to capture a screenshot of a web page from a given URL. It basically uses Firefox's rendering engine in order to generate a view of the page and then saves it to a JPG.
Sunday, May 3, 2009
Sharpening images
This piece of code shows how to sharpen a grayscale image (for color images do the same for each channel).
Sharpening is performed by applying a Laplacian operator on the image and adding the output to the original image.
Finally, this is the operator used (Laplacian+image):
-1 -1 -1
-1 9 -1
-1 -1 -1
-1 -1 -1
(see this nice application in which you can perform convolution with the above operator on a given image)
The code (assumes an image named imname is loadable, final output is stored in image named gray):
gray=cvLoadImage(imname,0)
imwidth = gray.rows
imheight = gray.cols
# convert to 32 bit
gray2=cvCreateImage (cvSize (imheight, imwidth), 32, 1)
for r in range(gray.rows):
for c in range(gray.cols):
gray2[r][c]=gray[r][c]
# define the filter:
lapl=cvCreateImage (cvSize (imheight, imwidth), 32, 1)
m=cvCreateImage (cvSize (3,3), 32, 1)
m[0][0]=-1
m[0][1]=-1
m[0][2]=-1
m[2][0]=-1
m[2][1]=-1
m[2][2]=-1
m[1][0]=-1
m[1][2]=-1
m[1][1]=8
cvFilter2D(gray2,lapl,m)
maxv=0
for r in range(gray.rows):
for c in range(gray.cols):
if(lapl[r][c]>maxv):
maxv=lapl[r][c]
for r in range(gray.rows):
for c in range(gray.cols):
v=int(255*lapl[r][c]/maxv)
gray[r][c]=gray[r][c]+v
maxv=0
for r in range(gray.rows):
for c in range(gray.cols):
if(gray[r][c]>maxv):
maxv=gray[r][c]
for r in range(gray.rows):
for c in range(gray.cols):
v=int(255*gray[r][c]/maxv)
gray[r][c]=v
Tuesday, April 14, 2009
This example is an application for displaying an image with the ability to stretch the window size arbitrarily (thus enabling to zoom in on the image):
from Tkinter import *
import Image, ImageTk
import sys
#
# an image viewer
class UI(Canvas):
if not sys.argv[1:]:
else:
root = Tk()
root.title(filename)
im = Image.open(filename)
UI(root, im)
root.mainloop()
from Tkinter import *
import Image, ImageTk
import sys
#
# an image viewer
class UI(Canvas):
def __init__(self, master, im):
x, y, orig_w, orig_h = im.getbbox()
Canvas.__init__(self, master,width=orig_w, height=orig_h)
tmpim = ImageTk.PhotoImage(im)
self.origim = im
self.image = tmpim
self.create_image(orig_w/2, orig_h/2, image=tmpim)
self.bind('
top=self.winfo_toplevel()
top.rowconfigure(0, weight=1)
top.columnconfigure(0, weight=1)
self.rowconfigure(0, weight=1)
self.columnconfigure(0, weight=1)
self.grid(sticky=N+S+E+W)
def resizeImage(self,event):
im = self.origim.resize((event.width, event.height),Image.ANTIALIAS)
tmpim = ImageTk.PhotoImage(im)
self.image = tmpim
self.create_image(event.width/2, event.height/2, image=tmpim)
if not sys.argv[1:]:
print 'need an image name!'
exit()
else:
filename = sys.argv[1]
root = Tk()
root.title(filename)
im = Image.open(filename)
UI(root, im)
root.mainloop()
Sunday, April 12, 2009
converting 8bit image to 32 bit image
If you have an 8bit source image and you want to convert it to a 32 bit image you do it using cvConvertScale:
newim = cvCreateImage (cvSize (src.rows, src.cols, 32, 1)
cvConvertScale(src,newim)
newim = cvCreateImage (cvSize (src.rows, src.cols, 32, 1)
cvConvertScale(src,newim)
Subscribe to:
Posts (Atom)