Showing posts with label Computer Graphics. Show all posts
Showing posts with label Computer Graphics. Show all posts

Feb 10, 2012

Changing the resolution (DPI) using ImageMagick

Converting the .tga format into .png:
----------------------------------------------
convert 1C1Y_snap.tga test.png
Changing its DPI from 72 dots per inch to 300 dots per inch:
-----------------------------------------------------------------------------
convert test.png -set units PixelsPerInch -density 300 test_3.png

Reference: ImageMagick
Reference: Using Photoshop Elements

Jul 5, 2011

Applet

CODEBASE = codebaseURL
ARCHIVE = archiveList
CODE = appletFile ...or... OBJECT = serializedApplet
ALT = alternateText
NAME = appletInstanceName
WIDTH = pixels HEIGHT = pixels
ALIGN = alignment
VSPACE = pixels HSPACE = pixels
>


. . .
alternateHTML


***CODEBASE = codebaseURL
This OPTIONAL attribute specifies the base URL of the applet--the directory that contains the applet's code. If this attribute is not specified, then the document's URL is used.

Useful attribute. Set this value to the URL location(including the bin path of .class files). In that case, just CODE attribute will
require just the applet class name. The important jar files(including the javaview.jar files that I needed) are pointed by the ARCHIVE attribute.

Ref: Making an applet

Jun 30, 2011

Name of the Angles



Know the angle type in Bengali but always confused when comes the english name.
Here it is. There should be no more confusion.

Apr 15, 2011

Computer Graphics and Animation in Bangladesh

Following link provides an overview of the area.
Animation in Bangladesh Overview
Following other links have related information:
1. Afgani Rana Youtube links
He has a company mediamax.tk. He has done more than 50 professional CG Animated products.

2. sample animation from Synaptics studio

3. Short film: Polkarella by Zubaer Kaolin

3. Grapha Online
Joined here to see the outcomes and people.

People to follow to get updates.

1. Dark Lord

2. Zubaer Kaolin

3. mehedi hoque

Sep 29, 2010

Project Bug: FlyTracking

I am struggling with my fly project code for couple of days.
Everything looks fine with my code and it works for some sets
of inputs while not working for others sets.

Usually I run 8 sets of sample together since I have 2 quad core
intel processor in my lab computer. These 8 should run simultaneously
without sharing processor among them.

But for some reasons my computer freaks out resulting in system hang
for some specific input sets. It processes out all the output image
but when generating the histogram it breaks.

I tried
i) reducing the processing set (2, 4, 6 sets at a time instead of 8)
ii) start debugging the histogram where I noticed the histogram
size is 2^31 which should not be for angle histogram(0 to 181).
Then I found it was the acos function from the cmath library that
was causing returning NAN for arguments -1.0 and 1.0. I changed
the argument type to float and now acos is working with the argument
of -1.0 and 1.0.

Some time seemingly insignificant thing makes one suffer a lot.
So it would be wise if every little detail is handled carefully
rather than assuming that trivial thing should work for granted.
I assumed that acos will work as usual but in the documentation
it states that if double is used as argument and the value of
argument is greater than 1.0 or less than -1.0 it should return
floating point exception.

Jul 8, 2010

Image Magick: Drawing some shapes

I need to draw some primitive shapes like circle, rectangle using image magick.
Here are the c++ codes that draws this shape.
Image img = new Image("100x100","black");

Line:
-----
img->draw( DrawableLine( centroid.first, centroid.second, static_cast(ev_x), static_cast(ev_y) ));

Circle Unfilled:
----------------
img->strokeColor("yellow");
img->fillColor("none");
img->draw(DrawableCircle(centroid.first, centroid.second, centroid.first + 25, centroid.second));

This code draws a circle of radius 25 pixels. The arguments it takes are
center_x, center_y, periemter_x, and periemeter_y.
It calculates the radius from the perimeter coordinates. That is why just provide any point on the circle as perimeter_x,perimeter_y.

To draw a filled circle just remove the second line.


Rectangle:
----------
img->draw(DrawableLine(centroid.first - 25, centroid.second - 25, centroid.first + 25, centroid.second - 25));
img->draw(DrawableLine(centroid.first + 25, centroid.second - 25, centroid.first + 25, centroid.second + 25));
img->draw(DrawableLine(centroid.first + 25, centroid.second + 25, centroid.first - 25, centroid.second + 25));
img->draw(DrawableLine(centroid.first - 25, centroid.second + 25, centroid.first - 25, centroid.second - 25));

Draws a rectangle using the lines from the centroid.
Rectangles can also be drawn using DrawableRectangle(). The arguments are respectively,
upper_left_x, upper_left_y, lower_left_x and lower_left_y
img->draw(DrawableLine(centroid.first - 5, centroid.second - 5, centroid.first + 5, centroid.second + 5));
Magick++

Nov 5, 2009

Image Magick: 32bit MacOSX installation

Mac OS X-specific Build instructions

Perform these steps as an administrator or with the sudo command:

* Install Fink. The default setup creates a /sw folder on your main hard
* drive. Make sure /sw/bin is in your path.
* Install the latest Xcode from Apple.
* Create a symbolic link in /Developer/SDKs/MacOSX10.4u.sdk/ to /sw:

cd /Developer/SDKs/MacOSX10.4u.sdk
ln -s sw /sw

* Use Fink, or FinkCommander to install any delegate libraries you
* require, for example:

fink install libjpeg

As a regular user or administrator:

* Download the ImageMagick source distribution.
* Unpack and change into the top-level ImageMagick directory:

tar xvfz ImageMagick-6.3.3-0.tar.gz
cd ImageMagick-6.3.3

* Choose an architecture and set your CFLAGS environment variable. Here we
* set CFLAGS for an Intel build:

export CFLAGS="-O -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk/ -arch i386 -I/sw/include/"

* Set your LDFLAGS environment variable to:

export
LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk/,-L/sw/lib/"

* Configure ImageMagick:

./configure --prefix=/sw --with-quantum-depth=16 \
--disable-dependency-tracking --with-x=yes \
--x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib \
--without-perl

* Build ImageMagick:

make

* Install ImageMagick:

sudo make install

* To test the ImageMagick GUI, start X11 and in a new shell and type:

display -display :0

May 30, 2009

Installing pngwriter: a library to write png image

To install pngwrite we need to install to helper library before we install pngwriter.
1. libpng
2. freetype2

We can use fink or macport to install them. Using macport

-> port install libpng
-> port install freetype

both will be installed on /opt/local directory.
(.h files in /opt/local/include .dylib files in /opt/local/lib)

Then we can download the pngwriter from here.
PNGWRITER

To install pngwriter
1. untar the zipped file.
The go inside the folder.
->make
->make install

This will install the pngwriter in /usr/local
(.h files in /usr/local/include and .dylib files in /usr/local/lib)

To use the pngwriter library we need just to add the pngwriter.h file.
#include (pngwriter.h)
int main()
{
pngwriter image(200, 300, 1.0, "out.png");
image.plot(30, 40, 1.0, 0.0, 0.0);
image.close();
return 0;
}
Let this be a sample program write_test.cpp.

To compile the program we need to the following command
g++ write_test.cpp -o test -I/opt/local/include/freetype2 -I/opt/local/include
-I/usr/local/include -L/usr/local/lib -L/opt/local/lib -lpng -lpngwriter -lz -lfreetype

(Note: you have to specifically give the include path for freetype -I/opt/local/include/freetype2 -I/opt/local/include.
And: since pngwriter is installed on /usr/local/include, so is the include path for pngwriter. The lib files are on -L/opt/local/lib (for freetype and libpng ) and -L/usr/local/lib ( for pngwriter ).

(Note: pngwriter assumes the lower left corner to be origin(0,0) and upper right corner is at (width, height))

Sample pngwriter code:
----------------------

This program reads two images and finds the HSV components (of the corresponding white region of the segmented binary image.) of the color image.

int main(int argc, char* argv[])
{
if ( argc < 4 )
{
cerr << "Usage: area " << endl;
return -1;
}
//
// MagickCore::SetMagickResourceLimit(MagickCore::MemoryResource, 1536);
// MagickCore::SetMagickResourceLimit(MagickCore::MapResource, 2048);
// Image* img = new Image(argv[1]);


map mapHSV_H;
map mapHSV_S;
map mapHSV_V;

// read the segmented image
pngwriter imageSegmented;
imageSegmented.readfromfile(argv[1]);

// read the color image

pngwriter imageColor;
imageColor.readfromfile(argv[2]);

int widthS = imageSegmented.getwidth();
int heightS = imageSegmented.getheight();

int widthC = imageColor.getwidth();
int heightC = imageColor.getheight();

int width, height;

if ( widthS == widthC && heightS == heightC) {
width = widthS, height = heightS;
} else {
cerr<<"Unequal dimension of the two input images"< exit(1);
}


for (int j=0; j for (int i=0; i
// read the segmented image if the pixel is white then find the HSV component of that pixel
double red = imageSegmented.dread(i, j, RGB_R);
double green = imageSegmented.dread(i, j, RGB_G);
double blue = imageSegmented.dread(i, j, RGB_B);

cout<<"R = "<

Notebooks

illuminate.google.com notebooklm.google.com