RSS/Atom feed Twitter
Site is read-only, email is disabled

Porting GIMP plugins to GEGL operations - GSOC 2011

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

3 of 3 messages available
Toggle history

Please log in to manage your subscriptions.

Porting GIMP plugins to GEGL operations - GSOC 2011 shivani maheshwari 04 Apr 08:24
Porting GIMP plugins to GEGL operations - GSOC 2011 shivani maheshwari 04 Apr 08:26
porting gimp plugins to gegl operations Mukund Sivaraman 12 Apr 11:11
shivani maheshwari
2011-04-04 08:24:36 UTC (about 14 years ago)

Porting GIMP plugins to GEGL operations - GSOC 2011

Hello sir,

I am Shivani 2nd year student at IIIT-Allahabad( Indian Institute Of Information Technology, Allahabad ). I have a programming experience with C, C++,QT and Java. Besides this I have also worked with OpenGl(glut/glu). I have Graphics Visualization and Computing as one of the core subject of this semester. Studying the plugins I find it very similar to using a combination of QT and opengl.
I am very eagerly interested in Image Manipulations and designing and I would like to contribute to porting the plugins to GEGL operations.Currently I am working on designing an UCI chess engine ( coding in C++ ) and making a virtual tour of my college campus by opengl.Both of the projects will be complete by the end of April.

Here is the code review and algorithm for the major files specified as a test ( please correct me if I am wrong ) -

*Cubism *-

header file - libgimp/gimp.h makes all basic plugin elements available to us.

Structures defined-
1. Polygon - containing detail for polygon construction

2. CubismVals - holds details for generation of tiles such as -tile saturation , tile size, background color and bool preview. background color - if no bg color specified then black is used while applying the filter.
tile size - determines size( in pixels ) of the square to be used. tile saturation- determines the intensity of the color of the squares thereby defining the opacity of square.

Local Variables - 1. cvals - storing default values for the parameters of the structure CubismVals.

2. GimpPlugInInfo PLUG_IN_INFO - Contains four pointers to different functions which are called during plugin execution. a)init - optional(can have null value) and is called as GIMP starts up. It can be called if we want to register some procedure conditionally on some files prescence.
b)quit - also optional( can have null value ) and is called when GIMP is going to close.
c)query - called when the plugin comes into existence or every time when it is modified.
d)run - it is the plugin processing function which receives the plugin name, input parameters, number of return values, pointer to output parameters.

MAIN() - it is a macro defined for calling the initialisation and calling appropriate functions that our plugin needs during its life time.

Functions -

1. query() - defines the input arguments Structure GimpParamDef contains - type, name and description. It registers the function in the path specified as here under "/Filters/Artistic"

2. cubism_dialog (GimpDrawable *drawable) - opens a dialog box for the user for specifying the basic input parameters. This also function holds the basic layout informaion for the dialog box. It clearly mentions the existence of two scale bars ( tile saturation,tile size ), preview window, toggle button( use background color ) and ok button. 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( signal - GTK_RESPONSE_OK ) or cancel button is pressed and the final parameters are then saved.

3. cubism (GimpDrawable *drawable,GimpPreview *preview) -

Every variable of the GimpDrawable struct has a drawable id, width, height,bytes per pixel,number of tile rows, number of tile columns, normal tiles and shadow tiles. Here we check if the drawable has an alpha channel associated with it. Alpha channel can be there with the layer types such as RGB, GRAYSCALE and it defines the amount of opacity of the layer.

Here in this function it checks whether cubism effect has to be applied in the preview window or on the main image and accordingly performs the task. For preview window -
It gets the preview window position and the preview area width, preview area height sets the bound and allocates 'sel_height * sel_width * bytes' memory locations of type guchar all initialised to 0 and pointed by dest.

If not preview - then directly set bounds based on drawable->id

Now we determine the background color. If it is set as default 'Black' then we initialise the bg_col array with 0, otherwise we get the background color and set the bg_col array with it. Then we calculate the number of rows and columns based on tile_size.

It fills the image based on the background color.

If it is for preview then it directly assigns each destination byte with the color in bg_color.
Otherwise - While creating the cubistic transformation it displays the progress bar having a label - 'Cubistic Transformation' . It now loops through every pixel and initialises the background color to the colour of the original image.Now 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 as (x2-x1)and height as (y2-y1).Based on tile size and random indices it calculates the random starting points( x, y ), then random width and height and random angle( theta ). It initialises a polygon, translates it to starting point( x,y ) and rotates it. Now by making use of CLAMP macro 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 and updates the image.

4. fill_poly_color (Polygon *poly,GimpDrawable *drawable, GimpPreview *preview,guchar *col,guchar *dest) -

It uses polygon fill algorithm(scanline) to fill the polygon. Find the distance between the two points, if the dist > 0 then initialise the vector vec by the unit vectors else by 0.Now we initialise the pixel region pointed by src_rgn, but the point to be noticed here is that we keep the last 2 parameters as TRUE, TRUE which define that the src_rgn will be used to write the shadow tiles. We first write the shadow tiles and then merge changes from the shadow tile to the current selected image.

polygon_extends function is used to calculate the minimum and maximum of x and y values and from it we initialise the size_y, size_x . Besides it min_scanlines, max_scanlines, min_scanlines_iter, max_scanlines_iter are also allocated memory and initialised. Now apply convert_segment for every two points of a segment to find min and max values.

After all prior calculations now we fill the polygon. A memory location vals of size = size_x is initialised.Now we use the vector 'vec' which we initialised in the begining of this function to calc_alpha_blend which returns the alpha value between 0.2 to 1.0 and the buf buffer is actually used to hold the color(+opacity) for each pixel

*Fractal trace - * *
*
header file - libgimp/gimp.h makes all basic plugin elements available to us.

Enumerator holding the types for the region outside the mandelbrot fractal - OUTSIDE_TYPE_WRAP, OUTSIDE_TYPE_TRANSPARENT, OUTSIDE_TYPE_BLACK, OUTSIDE_TYPE_WHITE

Structures defined- 1. parameter_t - it holds the input values for the mandelbrot fractal. x1 - minimum x value
x2 - maximum x value
y1 - minimum y value
y2 - maximim y value
depth - number of iterations
outside_type - type of layer outside the fractal. can have any value as defined in the enum above.

2. selection_t - parameters for the selected region - x1, y1, x2, y2, width, height, center_x, center_y

3. image_t - holds info about the image including its width, height, alpha value,bytes per pixel

4. pixel_t - holds the coloring info for each pixel including the RGB value along with alpha it any.

5. preview - holds the preview info including the preview obj, pixels, scale, width, height, bpp.
Local Variables -

1. GimpPlugInInfo PLUG_IN_INFO - Contains four pointers to different functions which are called during plugin execution. a)init - optional(can have null value) and is called as GIMP starts up. It can be called if we want to register some procedure conditionally on some files prescence.
b)quit - also optional( can have null value ) and is called when GIMP is going to close.
c)query - called when the plugin comes into existence or every time when it is modified.
d)run - it is the plugin processing function which receives the plugin name, input parameters, number of return values, pointer to output parameters.

MAIN() - it is a macro defined for calling the initialisation and calling appropriate functions that our plugin needs during its life time.

Functions -

1. query() - defines the input arguments Structure GimpParamDef contains - type, name and description. It registers the function in the path specified as here under "/Filters/Map"

2. pixels_init (GimpDrawable *drawable) -

initialises the pixel region pointed by *sPr , starting point (0,0) width and height being - image->width, image->height and the region will be used to read the actual drawable datas.

initialises the pixel region pointed by *dPr , starting point (0,0) width and height being - image->width, image->height and the region will be used to the region will be used to write to the shadow tiles.

initialise 2 references to 2 memory locations - spixel for source and dpixel for destination. Each of them hold the pixel values for each column In the next for loop we get all pixel of a row in spixel[y] and we iterate over from col 0 - height so as to cover whole image row wise.

3. pixels_free( ) - to free the source and destination pixel arrays.

4. pixels_get() - In this function each pixel is initialised the appropriate color + alpha value depending upon the bpp( bytes per pixel ) from the spixel .

5. pixels_get_biliner (gdouble x, gdouble y, pixel_t *pixel) - for a particular pixel it calculates x1 = floor(x) and x2 = x1+1 and then it gets the pixel color info for following pixels- (x1,y1),(x1,y2),(x2,y1)(x2,y2).After this it gets the aggregate alpha value and if this aggregate alpha value for the pixel(x,y) is not zero then it redefines the RGB values for that pixel

6. pixels_set (gint x, gint y, pixel_t *pixel ) - sets value for the destination pixel based upon the bpp for the current image.

7. pixels_store() -
sets the pixels pointed by dPr by values of buffer dpixel. It draws pixels from values (0,y) to (0+width-1,y).

8. mandelbrot (gdouble x, gdouble y, gdouble *u, gdouble *v) - This function calculates the x, y values till the iterator < depth. It initialises 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.

9. filter( GimpDrawable *drawable ) - calculate the scale_x and scale_y parameters. Iterate row wise from bottom to up and calculate px, py from mandelbrot. If the returned values lie between the image bounds i.e 0 < 0 ) set px = px + image.width and similarly for height and then use pixel_biliner() to get pixel color. 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() updates the progress bar labelled by "Fractal Trace" as the image is being mapped to destination .Finally the shadow tiles are merged and the drawable image is updated.

10. dialog_show() - Sets up the dialog box to set parameters for the mandelbrot fractal.There are groupped radio buttons including - Wrap, Transparent,Black, White for the outside type. 5 state bars exist each for x1,x2,y1,y2 and depth value and an ok button clicking on which leads to release of signal (GTK_RESPONSE_OK ) thereby saving the parameters and destroying the widget. We can change the parameters indefinitely and have a look in a preview window.

*Plasma - *
*
*
header file - libgimp/gimp.h makes all basic plugin elements available to us.

Structures defined-
1. PlasmaValues - it holds parameters - seed, turbulence,random_seed turbulence - controls complexity of plasma. High values give hard feeling to the cloud( like an abstract oil painting or mineral grains), low values produce a softer cloud (like steam, mist or smoke). The range is 0.1 to 7.0. random_seed - controls randomisation element.

Local Variables -

1. GimpPlugInInfo PLUG_IN_INFO - Contains four pointers to different functions which are called during plugin execution. a)init - optional(can have null value) and is called as GIMP starts up. It can be called if we want to register some procedure conditionally on some files prescence.
b)quit - also optional( can have null value ) and is called when GIMP is going to close.
c)query - called when the plugin comes into existence or every time when it is modified.
d)run - it is the plugin processing function which receives the plugin name, input parameters, number of return values, pointer to output parameters.
2. pvals - default plasma values.

MAIN() - it is a macro defined for calling the initialisation and calling appropriate functions that our plugin needs during its life time.

Functions -

1. query() - defines the input arguments Structure GimpParamDef contains - type, name and description. It registers the function in the path specified as here under "/Filters/Map"

2. plasma_dialog(GimpDrawable *drawable)- creates a dialog box for selecting the parameters for plasma view. It contains a preview window,preview toggle button, random seed, scale bar for turbulence.New seed button clicking on which sets new seed. Randomise check-button will set the seed using the hardware clock of the computer. Can change the parameters any number of time, have preview in preview window. On clicking the OK button GTK_RESPONSE_OK signal is released and final image is generated.

3. plasma( GimpDrawable *drawable, gboolean preview_mode ) - intialise a pixel by pixel_init(). It then checks in the selected figure a rectangle exists or a point. If it is not a point it will try to reduce it to a point by placing the seed pixel in all of the corners and then at the center as well.Now we recurse deep into the image by do_plasma until we reach the desired depth.

5. add_random( GRand *gr, guchar *pixel, gint amount ) - generates a random int between -amount to +amount for every alpha value and adds it to the pixel.

4. do_plasma()- calculates the center of the rectangle( xm, ym ). For depth = -1 it calculates the random values of color for the center of rectangle, corners of rectangle and center of each edge and then returns FALSE. For depth = 0 - it gets pixels for all the corner points.ran = (gint) ((256.0 / (2.0 * scale_depth)) * pvals.turbulence) is used to add_random values to the result.Now we do divide the region into four parts and based on that we do the analysis. For the left region - average the values, add_random values and put_pixel in the position. For the right region , top region , bottom region also do the same task.For the middle pixel it does the same work but first calculates the average from t1, br buffer and then average from b1, tr buffer and then the average of the two results obtained, followed by add_random and put_pixel in destination. If pixel depth is not zero then it calls this function recursively for the four different regions of the rectangle until the recurssion unwinds.

shivani maheshwari
2011-04-04 08:26:34 UTC (about 14 years ago)

Porting GIMP plugins to GEGL operations - GSOC 2011

Here are the other 3 files . I had to post in two different mails on account of size exceeding the limit of mail

*Gaussian blur-* *
*
Functions -

1.iir_young_find_constants (gfloat sigma, gdouble *B, gdouble *b) - Based on sigma( standard deviation of Gaussian distribution ) we calculate the constants. If sigma == 0 then to prevent ringing at the tile boundaries we define *B = 1 and b[0]=1,b[1]=b[2]=b[3]=0 else the value of the constants depend upon the parameter 'q'.

2. iir_young_blur_1D (gfloat * buf,gint offset, gint delta_offset, gdouble B, gdouble * b, gfloat *w, gint w_len)- in the forward filter we increase the offset every time we iterate by an amount = delta_offset till we reach the end. In backward filter we begin from the other extreme and every time we iterate to the left we decrease the offset by an amount = delta_offset 3. iir_young_hor_blur (GeglBuffer *src, const GeglRectangle *src_rect,GeglBuffer *dst,const GeglRectangle *dst_rect, gdouble B, gdouble *b) -
This is for INFINITE IMPULSE RESPONSE.Produces the horizontal blurring in the image.It expects the source and destination to be of same height and 0 y offset.

4. iir_young_ver_blur (GeglBuffer *src, const GeglRectangle *src_rect,GeglBuffer *dst,const GeglRectangle *dst_rect, gdouble B, gdouble *b) -
This is for INFINITE IMPULSE RESPONSE.Produces the vertical blurring in the image.It expects the source and destination to be of same width and 0 x offset.

5. fir_calc_convolve_matrix_length (gdouble sigma) - calculates the length of convolution matrix depending upon the standard deviation.

6. fir_gen_convolve_matrix (gdouble sigma, gdouble **cmatrix_p) - produces the convolution matrix cmatrix_p which is applied to the original image to produce gaussian blur.Each pixel's new value is set to a weighted average of that pixel's neighborhood. The original pixel's value receives the heaviest weight (having the highest Gaussian value) and neighboring pixels receive smaller weights as their distance to the original pixel increases.

7. fir_young_hor_blur (GeglBuffer *src, const GeglRectangle *src_rect,GeglBuffer *dst,const GeglRectangle *dst_rect, gdouble B, gdouble *b) -
Calculates horizontal blur for FINITE IMPULSE RESPONSE.It expects the source and destination to be of same height and 0 y offset.

8. fir_young_ver_blur (GeglBuffer *src, const GeglRectangle *src_rect,GeglBuffer *dst,const GeglRectangle *dst_rect, gdouble B, gdouble *b) -
Calculates vertical blur for FINITE IMPULSE RESPONSE.It expects the source and destination to be of same width and 0 x offset.

9.process (GeglOperation *operation, GeglBuffer *input,GeglBuffer *output, const GeglRectangle *result)-

GeglOperationAreaFilter base class allows defining operations where output data depends upon a neighbourhood with an input window that extends beyond the output window, the information about needed extra pixels in different directions should be set up in the prepare callback for the operation.Based on 'iir' or 'fir' it blurifies the image first horizontally and then vertically with different sets of functions used for both cases.

*Extras -* *
*
*Cartoon - *
*
*
header file - libgimp/gimp.h makes all basic plugin elements available to us.

Structures defined-
1. CartoonVals - holds parameters - mask_radius,threshold,pct_black mask_radius - size of area the filter works upon threshold - relative intensity difference which will result in darkening pct_black - decides the amount of black color added to the image

Local Variables - 1. cvals - storing default values for the parameters of the structure CartoonVals.

2. GimpPlugInInfo PLUG_IN_INFO - Contains four pointers to different functions which are called during plugin execution. a)init - optional(can have null value) and is called as GIMP starts up. It can be called if we want to register some procedure conditionally on some files prescence.
b)quit - also optional( can have null value ) and is called when GIMP is going to close.
c)query - called when the plugin comes into existence or every time when it is modified.
d)run - it is the plugin processing function which receives the plugin name, input parameters, number of return values, pointer to output parameters.

MAIN() - it is a macro defined for calling the initialisation and calling appropriate functions that our plugin needs during its life time.

Functions -

1. query() - defines the input arguments Structure GimpParamDef contains - type, name and description. It registers the function in the path specified as here under "/Filters/Artistic"

2. cartoon_dialog (GimpDrawable *drawable) - opens a dialog box for the user for specifying the basic input parameters. This also function holds the basic layout informaion for the dialog box. It clearly mentions the existence of two scale bars ( mask radius, percent black ), preview window and ok button. 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( signal - GTK_RESPONSE_OK ) or cancel button is pressed and the final parameters are then saved.

3. cartoon(GimpDrawable *drawable,GimpPreview *preview) -

Every variable of the GimpDrawable struct has a drawable id, width, height,bytes per pixel,number of tile rows, number of tile columns, normal tiles and shadow tiles. Here we check if the drawable has an alpha channel associated with it. Alpha channel can be there with the layer types such as RGB, GRAYSCALE and it defines the amount of opacity of the layer. Initialise 7 memory locations val_p1,val_p2,val_m1,val_m2,src,dest1,dest2. Initialise the pixel region pointed by 'src_rgn', new region being attached to drawable region,(0,0) as initial coordinates, width as drawable->width, height as drawable->height.

It then calculates the standard deviations - blur radius and mask radius. Now calculate the value of needed constants from the 'Gaussian-blur helper function' - find_constants.

Start the analysis of image by taking vertical strips into consideration begining from column 0 till width. gimp_pixel_rgn_get_col(col+x1, y1 ) gets all pixels in a column from (col+x1,y1) to (col+x1, y1+height-1 ) and fills the buffer src with it.sp_p1 holds the value for first pixel and sp_m1 holds the value for the last pixel and with these values and the values calculated by the find_constants functions we calculate every pixel along a column and then use the user defined function 'transfer_pixels' to transfer these pixel to the destination. gimp_progress_update() updates the progress bar for the current plugin.

Similary we analyse it now by taking horizontal strips begining from row 0 to row height.Initialise 4 memory locations for holding the values, 2 for the source buffer( src1, src2 ).Initialise the initial pixels i.e the starting row pixel 0 and width-1 and with the help of the values calculated from the gaussian function calculate every pixel along a row and use transfer_pixels() function to transfer these pixels to the destination. Thus we first move column-wise and then row-wise to analyse every pixel.

Compute the ramp value which sets 'pct_black' % of the darkened pixels black.Initialise and register the pixel region . dest1 deals with the calculations for blur radius and dest2 deals with the calculations for the mask radius.For every pixel calculate the diff as the ratio of the blur intensity to that of the average intensity.if the difference > threshold then multiplying factor = 1 else check if ramp != 0 then mult = (ramp - MIN (ramp, (cvals.threshold - diff))) / ramp. The final intensity for every pixel calculated as blur_ptr[col]*mult is CLAMPED between 0 to 255. If number of bytes per pixel is less than 3 then initialise denstination pixels directly and transfer the alpha value as well if the source has any. Otherwise if( bpp > 3 ) i.e RGB layers exist then convert the RGB values to the corresponding HLS values.
R[0-255](Red) G[0-255](Green) B[0-255](Blue) H[0-360](Hue) L[0-255](Lightness) S[0-255](Saturation) With it we set the lightness and again convert back the to RGB And after it we merge the shadow tile and update the drawable.

4. transfer_pixels (gdouble *src1, gdouble *src2, guchar *dest, gint jump, gint bytes, gint width) -

It is a gaussian blur helper function which transfer the pixels from source pointed by src1 and src2 to the destination 'dest'. If there are more than two bytes per pixel( if RGB ) then it computes the luminance value corresponding to the RGB triplet. The lightness value is computed as -
L = (max(R, G, B) + min (R, G, B)) / 2

5. compute_ramp (guchar *dest1, guchar *dest2, gint length, gdouble pct_black) -

It computes the ratio between the two destination images( blur, mask ) and it calculates the number of pixels 'count' for which this difference is < 1. Now it calcultes the average such that avg = ( hist[0] + hist[1] + hist[2] + .............+ hist[n] ) /count where 'n' is the index where avg > pct_black and at that point where we reach the desired pct_black the function returns the ramp as ( 1 - n/100 )

*Photocopy - * *
*
header file - libgimp/gimp.h makes all basic plugin elements available to us.

Structures defined-
1. PhotocopyVals - holds parameters - mask_radius,sharpness,threshold,pct_black,pct_white mask_radius - controls the size of the pixel neighbourhood over which the average intensity is computed and then compared to each pixel in the neighborhood to decide whether or not to darken it. Large values result in very thick black areas bordering the regions of white and much less detail for black areas. Small values result in less toner overall and more details everywhere.
sharpness - defines photocopy sharpness. threshold - relative intensity difference which will result in darkening pct_black - decides the amount of black color added to the image pct_white - white pixel percentage.

Local Variables - 1. pvals - storing default values for the parameters of the structure PhotocopyVals.

2. GimpPlugInInfo PLUG_IN_INFO - Contains four pointers to different functions which are called during plugin execution. a)init - optional(can have null value) and is called as GIMP starts up. It can be called if we want to register some procedure conditionally on some files prescence.
b)quit - also optional( can have null value ) and is called when GIMP is going to close.
c)query - called when the plugin comes into existence or every time when it is modified.
d)run - it is the plugin processing function which receives the plugin name, input parameters, number of return values, pointer to output parameters.

MAIN() - it is a macro defined for calling the initialisation and calling appropriate functions that our plugin needs during its life time.

Functions -

1. query() - defines the input arguments Structure GimpParamDef contains - type, name and description. It registers the function in the path specified as here under "/Filters/Artistic"

2. photocopy_dialog (GimpDrawable *drawable) - opens a dialog box for the user for specifying the basic input parameters. This also function holds the basic layout informaion for the dialog box. It clearly mentions the existence of 4 scale bars ( mask radius, sharpness, percent white, percent black ), preview window and ok button. 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( signal - GTK_RESPONSE_OK ) or cancel button is pressed and the final parameters are then saved.

3. photocopy(GimpDrawable *drawable,GimpPreview *preview) -

Every variable of the GimpDrawable struct has a drawable id, width, height,bytes per pixel,number of tile rows, number of tile columns, normal tiles and shadow tiles. Here we check if the drawable has an alpha channel associated with it. Alpha channel can be there with the layer types such as RGB, GRAYSCALE and it defines the amount of opacity of the layer. Initialise 6 memory locations val_p1,val_p2,val_m1,val_m2,dest1(blur radius),dest2(mask radius). Initialise the pixel region pointed by 'src_rgn', new region being attached to drawable region,(0,0) as initial coordinates, width as drawable->width, height as drawable->height. It desaturates the image, computes transfer and then calculates the standard deviations - sharpness and mask radius. Now calculate the value of needed constants from the 'Gaussian-blur helper function' - find_constants.

Start the analysis of image by taking vertical strips into consideration begining from column 0 till width. gimp_pixel_rgn_get_col(col+x1, y1 ) gets all pixels in a column from (col+x1,y1) to (col+x1, y1+height-1 ) and fills the buffer src with it.sp_p1 holds the value for first pixel and sp_m1 holds the value for the last pixel and with these values and the values calculated by the find_constants functions we calculate every pixel along a column and then use the user defined function 'transfer_pixels' to transfer these pixel to the destination. gimp_progress_update() updates the progress bar for the current plugin.

Similary we analyse it now by taking horizontal strips begining from row 0 to row height.Initialise 4 memory locations for holding the values, 2 for the source buffer( src1, src2 ).Initialise the initial pixels i.e the starting row pixel 0 and width-1 and with the help of the values calculated from the gaussian function calculate every pixel along a row and use transfer_pixels() function to transfer these pixels to the destination. Thus we first move column-wise and then row-wise to analyse every pixel.

Compute the ramp values - ramp_up and ramp_down.ramp_up sets the pct_black whereas ramp_down sets the pct_white of the pixels.

Initialise and register the pixel region . dest1 deals with the calculations for blur radius and dest2 deals with the calculations for the mask radius.For every pixel calculate the diff as the ratio of the blur intensity to that of the average intensity.
If diff < threshold and if ramp_down != 0 then mult = (ramp_down - MIN (ramp_down, (pvals.threshold - diff))) / ramp_down. The lightness for every pixel calculated as blur_ptr[col]*mult is CLAMPED between 0 to 255. Else if diff > threshold and ramp_up ! = 0 then mult = MIN (ramp_up, (diff - pvals.threshold)) / ramp_up. The lightness for every pixel calculated as 255 - (1.0 - mult) * (255 - blur_ptr[col]) CLAMPED between 0 to 255.

Check If number of bytes per pixel is less than 3(grayscale / grayscale+alpha) or bpp > 3 ( RBG/RGB+alpha ) and accordingly set the destnation pixel.
And after it we merge the shadow tile and update the drawable.And free the unused buffers.

4. transfer_pixels (gdouble *src1, gdouble *src2, guchar *dest, gint jump, gint bytes, gint width) -
It is a gaussian blur helper function which transfer the pixels from source pointed by src1 and src2 to the destination 'dest'.

5. compute_ramp (guchar *dest1, guchar *dest2, gint length, gdouble pct_black) -

It computes the ratio between the two destination images( blur, mask ) and checks if the diff is under_threshold or not.It calculates the number of pixels 'count' for which this difference is < threshold ,diff > threshold && diff < 2
Now it calculates the average such that avg = ( hist[0] + hist[1] + hist[2] + .............+ hist[n] ) /count where 'n' is the index where avg > pct, now check if diff was under_threshold then return (pvals.threshold - (gdouble) n / 1000.0) else return ((gdouble) n / 1000.0 - pvals.threshold) *
*
*
*
This was what I understood to the best of my knowledge and looking forward for suggestions to improve it or do some other task. Besides this I will submit the sample implementation of new GEGL OP as a patch against the gegl main branch by today evening.

Thanking you in advance

Mukund Sivaraman
2011-04-12 11:11:06 UTC (about 14 years ago)

porting gimp plugins to gegl operations

Shivani,

I have asked you before not to mail me directly. All GIMP GSoC discussions have to be public. I am not your mentor yet, and may not mentor at all. Please send email to the gimp-developer list and not to me.

Mukund

On Tue, Apr 12, 2011 at 03:51:09AM -0700, shivani maheshwari wrote:

Hello,

Sorry for the late reply. I was out of town on so got to read the mail today.
I'll look into the code again and do the needful as soon as possible.

-- Shivani Maheshwari
Under Graduation( BTech.)
Indian Institute of Information Technology, Allahabad (Amethi Campus)
India