GSoC 2011 application

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





Dear Sir,

I am Ravi Bhushan final year student at LNM IIT(The LNM Institute Of Information Technology). I have strong background in C Programming and User-interface Programming(Like GTk+).
My area of interest is Image Processing and Computer Vision and Pattern Recognition which was the core subjects in my curriculam during B.Tech. I have already worked on some of the open-source software likes Greenstone DL and Moodle. I have customized Moodle server and Greenstone DL for my institute and Currently, it is extensively used in my Institute's Digital Library.

I am eager to implement  the project entitled "Porting GIMP Plugin to GEGL Operation". As per the pre-requisite, I am sending the code-reviews :-


Plasma

Including libgimp/gimp.h avails all the basic plugins of GIMP to this program.

Global Variables :

SCALE_WIDTH = 48
TILE_CACHE_SIZE= 32

Defined Structures :

 PlasmaValues- Holds values of seed, turbulence and random_seed which is the input values given to this program by user.

Defined local variables :
1. pvals - It is the default plasma value if user doesn't change the value through dialog box.
2.GimpPlugInInfo PLUG_IN_INFO : It contains 4 pointers
   init - initialise the process (Optional)
   quit - quit the procedure (Optional)
   query- It is called when a new plugin comes into existence or there is some modification in the existing plugin.
   run - It is the main function by which plugin works. It takes plugin name, input parameters, number of return values, pointer to output parameters as input.

MAIN() - program execution starts from here.

Functions :

1. query() : Defines the input argument. It takes seed, turbulence and image as input.
             It registers the plugin under Image/FIlters/Render/Clouds.

2. run()   : If there is no GIMP_PDB_CALLING_ERROR, it calls plasma function to operate on Image.

3. plasma_dialog() : when user clicks on Image/Filters/Render/Clouds/Plasma, it gives a dialog box to take input from users. It ask users to change the values of seed and turbulence. If user doesn't change these values, it will take default values of parameters defined by pvals.

User can change the parameters any number of  times and see the preview. On clicking the OK button, GTK_RESPONSE_OK signal is released.It will check whether the drawable is rgb or indexed,final images will be produced by calling plasma() function. After that the dialog_box will be destroyed.
 
4. init_plasma(GimpDrawable *drawable,gboolean preview_mode,GRand *gr))

   if preview-mode is true, it will start the image at (0,0) and will set the width and height of the preview and preview_buffer= image_width*image_height*bpp. If preview_mode is false, it will set the mask_bound from ix1 to ix2 and iy1 to iy2. Finally it will return a pointer *pft ehich will point to the drawable first pixel.

5. plasma(GimpDrawable *drawable, gboolean preview_mode) :

   It initialise the pixel by calling init_plasma function.For the first iteration, it puts the seed pixels each corners,middle of each edge and center of the pixel. Then, it continues to go in depth by calling do_plasma function till we get a point. After getting a point, we put the randomised pixel value at that position and then, we call end_plasma() function.

6. do_plasma() :

 It calculates the centre of rectangle.For depth=-1, it calculates the random values of color for the pixels located at top-left,top-right,bottom-left,bottom-right,middle-left,middle-right,middle-top,middle-bottom and center of the rectangle and then return FALSE.

 For depth=0, it gets pixels for all the corner point and pixel information in guchar tl,tr,bl,br array. The variable ran = (gint) ((256.0 / (2.0 * scale_depth)) * pvals.turbulence) gives a random value to add to the result.

 After that, we divide the rectangular region in four parts and we analyse every every parts individually. For the left region, average the values, add_random values and put_pixel(Putting pixel values at the specified position) in the position. Same task we do for other regions also.

For depth not equal to 0 or -1, it calls the function do_plasma() recursively(for each region of the rectangle) to go in further depth.It reduces the values of depth on every call and finally depth becomes equal to 0.

Fractal-Trace


Including libgimp/gimp.h avails all the basic plugins of GIMP to this program.

Here we have four types of mandelbrot fractal which is chosen by user by deciding the value OUTSIDE_TYPE_WRAP(0),  OUTSIDE_TYPE_TRANSPARENT(1),  OUTSIDE_TYPE_BLACK(2),  OUTSIDE_TYPE_WHITE(3).

Defined Structures :

1.  parameter_t : holds the input values of mandelbrot fractal chosen by user.
                  x1 : Distance from left.
                  x2 : Distance from right.
                  y1 : Distance from top.
                  y2 : Distance from bottom
                  depth :decides number of iteration. 
                  outside_type : defines type of mandelbrot fractal
       
2. selection_t : holds the user input x1, y1, x2, y2 and width, height, center_x, center_y of selection chosen by user.

3. image_t : holds info about the image(width, height, alpha,bytes per pixel).

4. pixel_t  : holds the colour info for each pixel including the RGB value along with alpha(If there exists alpha channel).

Globally Defined Variable :

PREVIEW_SIZE 200

Defined Local Variable :

1. GimpPlugInInfo PLUG_IN_INFO : It contains 4 pointers.
   init - initialise the process (Optional)
   quit - quit the procedure (Optional)
   query- It is called when a new plugin comes into existence or there is some modification in the existing plugin.
   run - It is the main function by which plugin works. It takes plugin name, input parameters, number of return values, pointer to output parameters as input.
 
2. parameters : Default value of parameters x1,x2,y1,y2 , depth and outside_type after opening dialog_box.

3. selection
4. image
5. preview

Functions :

1. query() : Defines the input argument. It takes x1,x2,y1,y2,depth and outside_type as input.
             It registers the plugin under Image/FIlters/Map.

2. run() : First of all, it initialise the drawable parameter like width , height ,bpp, alpha,selection_width, selection_height,center_x,center_y.After that, we intialises the pixels by calling pixel_init() function. Run() function will check for the  GIMP_PDB_EXECUTION_ERROR(if any) due to the wrong format of image. It will take actions according to the values of run-mode. If it is interactive, it will provide a dialog_box to the users and if it is non-interactive, it will check for the proper number of arguments and if it is less, it will give execution error.We can also run the program with the last_values of parameters.

3. pixels_init (GimpDrawable *drawable) : Initialises the pixel region pointed by *sPr and *dpr.  starting point would be (0,0), width and height would be image->width, image->height and the region pointed by sPr will be used to read the actual drawable datas and region pointed by dPr will be used to write the data.

 We also initilises two memory location sPixels[y] and dPixels[y] which will store pixels colouring information of a row for a particular height(y).

4. pixel_free() : It is used to free the memory location occupied bt sPixels and dPixels array.

5. pixels_get (gint x,gint y,pixel_t *pixel) :
      It initialises the pixels colouring information according the type of image(RGB, RGB+A,GRAY, GRAY+A) and stores into Pixel->r,g,b,a variable defined in pixel_t structure.

6. pixels_get_biliner (gdouble x,gdouble y,pixel_t *pixel) : For a particular pixel, we calculates x1 = floor(x) and x2 = x1+1(Here x1 and x2 are the x-position of the neighbouring pixel of pixel located at (x,y)).

Also, we calculate y1=floor(y) and y2=y1+1 and then it gets the pixel color information for these pixels-  (x1,y1),(x1,y2),(x2,y1)(x2,y2).These 4 pixels will be neighbouring pixels of the (x,y) pixel.

Then, we calculate the aggregate alpha value by formula mentioned below

alpha = 1.0001*(a * (gdouble) A.a + b * (gdouble) B.a + c * (gdouble) C.a + d * (gdouble) D.a);

and if this aggregate alpha value for the pixel(x,y) is not zero then we redefine the RGB values of that particular pixel.

7. pixels_set (gint x, gint y, pixel_t *pixel ) : It sets value for the destination pixel using dPixels[y] array according to the bpp for the source image.

8. pixels_store (void) : It sets the pixels pointed by dPr by values of dpixel[y]. It draws pixels from values (0,y) to (0+width-1,y) and we do this for evey y.

9. mandelbrot (gdouble  x, gdouble  y, gdouble *u, gdouble *v) :  It initialises local variables xx = x, yy = y.And then on every iteration yy = 2*xx*yy + y and xx = x^2 - y^2 + x and updated x^2 = xx and y^2 = yy  after every iteration. After every itration we increase iter by 1 and we continue this iteration till iter is less than the depth parameter. This function would return the final values of *u and *v and it will be stored as px and py in the calling function.

10. filter( GimpDrawable *drawable ) :
(a) calculate the scale_x and scale_y parameters.
(b) We traverse the drawable row wise  and calculate px, py from mandelbrot function. If the returned values lie between the image bounds i.e 0 <= px <= width and 0 <= py <= height then apply pixel_biliner to calculate corresponding color and alpha value which would be stored in pixel->r,g,b,a variable defined under structure pixel_t.
(c) Else, if values of px and py doesn't lies in the image bound, it makes use of enum variable.

In case of enum= OUTSIDE_TYPE_WRAP : if( px < 0 ) px = px + image.width and similarly for height and then use pixel_biliner() to get pixel color of the pixel located by (px,py) which is now in the image bound.
In case of OUTSIDE_TYPE_TRANSPARENT : r = g = b = a = 0;
In case of OUTSIDE_BLACK : r = g = b = 0, a = 255
In case of OUTSIDE_TYPE_WHITE : r = g = b = a = 255
 

gimp_progress_update() shows the progress bar labelled by "Fractal Trace" as the image is being mapped to destination .The progress bar is calculated with the help of selection width and height. Finally the shadow tiles are merged and the drawable image is updated.

11. dialog_show() -
It sets up the dialog box and give a previlege to users to set  parameters for the mandelbrot fractal.There are radio buttons including - Wrap, Transparent,Black, White for the outside type.
The values of these radio-buttons is stored in enum variable, which is respectively 0,1,2 and 3.
There exist a bar to set the value of variable for each of x1,x2,y1,y2 and depth value and an ok button.On clicking it releases signal GTK_RESPONSE_OK ,which results saving the parameters and destroying the widget. We can change the parameters indefinitely and have a look in a preview window.

12. dialog_preview_setpixel (gint x,gint y,pixel_t *pixel) : It sets the colouring information of the pixls in the preview window.

13. dialog_preview_init (void) : It initialises the preview window parameters like preview width,height and scale.


Cubism

Including libgimp/gimp.h avails all the basic plugins of GIMP to this program.

Global Variables :
SCALE_WIDTH =  125
BLACK       =    0init - initialise the process (Optional)
   quit - quit the procedure (Optional)
   query- It is called when a new plugin comes into existence or there is some modification in the existing plugin.
   run - It is the main function by which plugin works. It takes plugin name, input parameters, number of return values, pointer to output parameters as input.
BG          =    1
SUPERSAMPLE =    4
MAX_POINTS  =    4
RANDOMNESS  =    5

Structures :

1. Polygon : It contains details of a polygon like number of pts in a polygon and information about that point.

2. CubismVals : It contains the information about tile_size,tile_saturation(defines intensity of colour),bg_color,preview.

Local Variables :

 1. cvals : It stores default values for the parameters of the structure CubismVals. If user doen't choose any values through the dialog_box, the cubism will take these values for operation.

 2. GimpPlugInInfo PLUG_IN_INFO : It contains four pointers.
        init : initialise the process (Optional)
        quit : quit the procedure (Optional)
        query : It is called when a new plugin comes into existence or there is some modification in the existing plugin.
        run : It is the main function by which plugin works. It takes plugin name, input parameters, number of return values, pointer to output parameters as input.


Functions :

1. query() :  Defines the input argument. It takes tile_Saturation,bg_color and tile_size as input.
             It registers the plugin under Image/FIlters/Artistic.

2. run()  :   This function will check for the  GIMP_PDB_EXECUTION_ERROR(if any) due to the wrong format of image. It will take actions according to the values of run-mode. If it is interactive, it will provide a dialog_box to the users and if it is non-interactive, it will check for the proper number of arguments and if it is less, it will give execution error.We can also run the program with the last_values of parameters.

3. cubism_dialog (GimpDrawable *drawable) :  It provides a dialog box for the user for choosing the input parameters and defines the lay-out of dialog_box. User can change the value of parameters and have a preview for every changed argument.The widget does not gets destroyed until the ok button(GTK_RESPONSE_OK signal releases) or cancel button is pressed and the final parameters are then saved for the next time.

4. cubism (GimpDrawable *drawable,GimpPreview  *preview) :

  (a) If preview is true, we set the parameter of preview like x1,y1(starting pixels), selection_width and selection_height. By this, we can calcute the final pixel position as x2,y2.
  (b) If preview is false, we choose a mask bounded by x1 and x2, y1 and y2.

  If background color(bg_col) is BLACK then we put 0 for all the bytes position in a pixel.Else, we put actual bg_color at every pixel. Function fills the image with the background color.

   If it is for preview then it directly assigns each destination byte with the color in bg_color.
   Else,cubistic transformation displays the progress bar having a label - 'Cubistic Transformation'.

   Now, It  traverse every pixel and initialises the background color to the colour of the original image.Based on the number of rows and columns, it calculates the number of tiles.
 
   Initialise a pixel region pointed by src_rgn,new region being attached to drawable region, (x1,y1) as initial coordinates, width=(x2-x1)and height=(y2-y1).

   Based on tile size, cols and random indices array it determines the random starting points( x, y ), then random width and height and random angle( theta ). It initialises a polygon by calling function polygon_reset(). After that, we add four points in the polygon. These vectors are translated based upon the values of tx and ty and rotated based on the values calculated by theta. By making use of CLAMP, it checks whether the starting point x and y lie within the specified range (x1, x2-1) and (y1, y2-1) respectively then it fills the buffer pointed by col with the value of pixel (ix,iy) in the region src_rgn.col. It fills the respective polygon by calling fill_poly_color() function and updates the image.
 
5. fill_poly_color (Polygon *poly,GimpDrawable *drawable, GimpPreview  *preview,guchar *col,guchar *dest) :

  First of all, it calculates the distance between two points in a polygon, and define x and  y vector between them. After that we call polygon_extends() function to get the extreme positions of polygon using min_x,max_x, min_y and max_y variable and from these values,we initialise the size_y=(max_y - min_y) * SUPERSAMPLE and  size_x =(max_x - min_x) * SUPERSAMPLE;

 Now, it determines the colors suitable for the polygon by comparing with the pixel values of the src_rgn at the polygon's position, and fills the polygon with the color values holded by buf  array(Contains color values at each pixels).



Regards,

--

RAVI BHUSHAN
Undergraduate Final Year,
Computer Engineering,
The LNMIIT,
+91-9462135022



_______________________________________________
Gimp-developer mailing list
Gimp-developer@xxxxxxxxxxxxxxxxxxxxxx
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer

[Index of Archives]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [GIMP for Windows]     [KDE]     [GEGL]     [Gimp's Home]     [Gimp on GUI]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux