On Tue, Mar 29, 2011 at 11:57 PM, sourav de <souravde1...@gmail.com> wrote:
> > > On Tue, Mar 29, 2011 at 1:15 PM, sourav de <souravde1...@gmail.com> wrote: > >> >> >> On Tue, Mar 29, 2011 at 4:11 AM, Mukund Sivaraman <m...@banu.com> wrote: >> >>> Hi Sourav >>> >>> On Tue, Mar 29, 2011 at 12:36:04AM +0530, sourav de wrote: >>> > Hi, >>> > >>> > I am a 2nd year student of the department of Computer Science and >>> > Engineering at Indian Institute of Technology, Kharagpur ,and I am >>> > interested in the plugin for cartoonization of an image in GIMP. >>> >>> I gather you want to modify the cartoon plug-in in GIMP? >>> >>> The plug-in porting task that you have mentioned in the subject is to >>> directly port GIMP plug-ins to GEGL ops. No modification of >>> functionality is necessary. It is described here: >>> >>> >>> http://gimp-wiki.who.ee/index.php?title=Hacking:GSoC_2011/Ideas#Porting_GIMP_plugins_to_GEGL_operations >>> >>> It is not a task of porting only 1 plug-in, but about 6-10 plug-ins per >>> student. 1 plug-in is a very easy task and will not be sufficiently >>> long for a full summer's work. >>> >>> To apply for this task, please present the items mentioned on the >>> linked wiki page. >>> >>> ---- >>> >>> However, if you wish to modify the cartoon plug-in, that sounds >>> interesting too. It can be a different task. Can you describe what is >>> lacking in the current approach in the GIMP plug-in? What is the >>> algorithm that you plan to use ? You say you are doing a project on >>> algorithmic art.. have you published anything on the methods you wish >>> to use in this cartoon plug-in? Are you using any other published >>> works? >>> >>> Note that we _may_ accomodate more tasks if they are of a high quality >>> and we are satisfied with how the student presents it. >>> >>> Mukund >>> >> >> Thank you sir, for your comments, I'll come up with the presentation of >> those plug-ins mentioned in the wiki page and algorithm for the >> cartoonization plug-in soon. >> And for the project on algorithmic art, I took this project in my >> current semester, I'll have to take the course Computer Graphics in my next >> semester to complete the project. So far I haven't yet publish any paper. >> >> >> -- >> Sourav De >> 2nd Year Student >> Department of Computer Science and Engineering >> IIT KHARAGPUR >> >> > I wrote the code review for gaussian blur as it given here > > http://git.gnome.org/browse/gegl/tree/operations/common/gaussian-blur.c > > > But I'm not familiar with writing code review and algorithmic > description. Here goes my code review. > > > <---code review starts here> > > Gaussian blur operation code review: > > 1. function-1 : static void iir_young_find_constants (gfloat sigma,gdouble > *B,gdouble *b) > > a. the variable sigma is to avoid unexpected ringing at tile boundaries of > an image. > b. there exists a variable q, whose value must be remained in between 0 - > 1.5, and according to the value of sigma there are two procedures to > calculate the value of q. > c. lastly it sets the value of the variables b[0] to b[3] and B, and then > returns. > > 2. function-2 : static inline void iir_young_blur_1D (gfloat * buf,gint > offset,gint delta_offset,gdouble B,gdouble *b,gfloat * w,gint w_len) > > a. this function blurrifies an image one dimensionally. > b. wlen is the length of the 1d array w passed. > c. here an image would be blurrified in two steps, applying forward and > backward filter for each pixel, a local variable wcount counts the number of > pixels each time. > d. the filter would be applied to the image according to the passed array > w. > > 3. function-3 : static void iir_young_hor_blur (GeglBuffer *src,const > GeglRectangle *src_rect,GeglBuffer *dst,const GeglRectangle > *dst_rect,gdouble B,gdouble *b) > > a. this function blurrifies an image horizontally. > b. first it creates an one dimensional array buf whose length is > height*width*4, where height and width is height and width of the source > image rectangle. > c. then it creates another one dimensional array w with the length of the > width of the source image. > d. after then it fills the values of buf array according to the source > image in RaGaBaA format. > e. then it applies the iir_young_blur_1D function to the newly generated > ractangles. > f. lastly it stores the change in a destination array and returns. > > 4. function-4 : static void iir_young_ver_blur (GeglBuffer *src,const > GeglRectangle *src_rect,GeglBuffer *dst,const GeglRectangle > *dst_rect,gdouble B, gdouble *b) > > a. this function blurrifies an image vertically. > b. first it creates an one dimensional array buf whose length is > height*width*4, where height and width is height and width of the source > image rectangle. > c. then it creates another one dimensional array w with the length of the > height of the source image. > d. after then it fills the values of buf array according to the source > image in RaGaBaA format. > e. then it applies the iir_young_blur_1D function to the newly generated > ractangles. > f. lastly it stores the change in a destination array and returns. > > 5. function-5 : static gint fir_calc_convolve_matrix_length (gdouble sigma) > > a. depending upon the value of sigma it returns an integer which partially > determines the width and height of the convolution matrix for image > transformation. > > 6. function-6 : static gint fir_gen_convolve_matrix (gdouble sigma,gdouble > **cmatrix_p) > > a. first it sets the value of matrix-length by calling > fir_calc_convolve_matrix_length function with sigma passed as a variable. > b. then it creates the convolution matrix. > c. finally it completes the whole convolution matrix by certain > calculation, copies it to the cmatrix_p, and returns matrix_length. > > 7. function-7 : static inline float fir_get_mean_component_1D (gfloat * > buf,gint offset,gint delta_offset,gdouble * cmatrix,gint matrix_length) > > a. it returns the mean of the 1d array buf created previously, > > 8. function-8 : static void fir_hor_blur (GeglBuffer *src,const > GeglRectangle *src_rect,GeglBuffer *dst,const GeglRectangle *dst_rect, > gdouble *cmatrix,gint matrix_length,gint xoff) > > a. this function also blurrifies an image horizontally, by creating a > buffered array,but it blurrifies with a rectangle of given width and height, > and offsets between source and destination array according to the value of > xoff and radius. > > 9. function-9 : static void fir_ver_blur (GeglBuffer *src,const > GeglRectangle *src_rect,GeglBuffer *dst,const GeglRectangle *dst_rect, > gdouble *cmatrix,gint matrix_length,gint off) > > a. this function also blurrifies an image verically, by creating a buffered > array,but it blurrifies with a rectangle of given width and height, and > offsets between source and destination array according to the value of yoff > and radius. > > > <code review ends here---> > > Can anyone please help me with writing code review of a given code, by > telling me whether it's a proper way to write code review or not? > > > -- > Sourav De > 2nd Year Student > Department of Computer Science and Engineering > IIT KHARAGPUR > > Hi everyone, here is my code review for some of the plug-ins mentioned in Gsoc-wiki page, *Cubism plug-in code review* 1. first it creates two structures a. cvals (of CubismVals ), which includes some tile properties, preview option b. PLUG_IN_INFO (of GimpPlugInInfo) 2. function 1: static void cubism (GimpDrawable *drawable,GimpPreview *preview) a. this function first checks whether there is an alpha chanel exits in the image or not. b. then it goes for the preview option. If it's still not set, then it sets the upper left and lower righthand corners of the bounding box which previews the image operation. c. then it checks the body color, if it's not already black, it sets it to the original images body color. d. it then calculates number of tiles and randomizes indices for each tile. e. then it calls gimp_pixel_rgn_init function to initialize the operation. e. after that it calculates the starting point co-odinates, height, width and angel of rotation for each tile and adds them to the desired polygons. f. finally it slightly rotates and translates them. 3. function 2: static void fill_poly_color (Polygon *poly,GimpDrawable *drawable,GimpPreview *preview,guchar *col,guchar *dest) a. first of all it calculates the distance between two points in a polygon, and define x & y vector between them. b. then by calling polygon_extents it gets the extreme positions of the polygon. c. from those positions it obtains the size of the polygon, minimum and maximum number of scanlines for it. d. then it determines the colors suitable for the polygon by comparing with the pixel values of the source image at the polygon's position, and fills the polygon with them. 4. Main function a. it fetches the image first. b. then it checks for the run mode, if it's interactive then it starts with the default data, else it takes data from user. c. after that it calls the cubism function, proceeds with cubism effects, in the mean time it also keep flushing the display if run mode is non- interactive. 5. static gboolean cubism_dialog (GimpDrawable *drawable) : function a. it opens up a dialogue box for the cubism and sets it's parameters. b. it keeps on changing, toggling, swapping the display if user does some change in those cubism parameters. c. lastly it finalizes the event when user hits the OK button or CANCEL button. *Plasma plug-in code review *1. first it creates two structures a. pvals (of PlasmaValues ), which includes some plasma properties like seeds, turbulance, random speed. b. PLUG_IN_INFO (of GimpPlugInInfo) 2. function 1: static void plasma_seed_changed_callback (GimpDrawable *drawable,gpointer data) a. this function calls plasma function 3. function 2: static void plasma (GimpDrawable *drawable,gboolean preview_mode) a. it initializes the plasma operation by calling init_plasma function b. after that it puts seed pixels , one in each corner, and one in the center of each edge, plus one in the center of the image by calling do_plasma function. c. then it continues to go in further depths as much as possible and keeps up the plasma operation. d. finally it ceases the procedure by calling end_plasma function 4. function 3: static GimpPixelFetcher* init_plasma (GimpDrawable *drawable,gboolean preview_mode,GRand *gr) a. it checks for the preview option, alpha channel and initializes the plasma operation. 5. function 4: static gboolean do_plasma (GimpPixelFetcher *pft,gint x1,gint y1,gint x2,gint y2,gint depth,gint scale_depth,GRand *gr) a. it calculates the medians and for that first it checks the depth. b. if depth=-1, then it generate random colors and put them into the corners and center of the image. c. else it takes the pixels from the given image and randomly obtain pixel values according to the turbulance,then adds them and obtains average. d. finally it goes for the higher depth by calling itself recursively. 6. Main function a. it fetches the image first. b. then it checks for the run mode, if it's interactive then it starts with the default data, else it takes data from user. c. after that it calls the plasma function, in the mean time it also keep flushing the display if run mode is non- interactive. 7. static gboolean cubism_dialog (GimpDrawable *drawable) : function a. it opens up a dialogue box for the plasma and sets it's parameters. b. it keeps on changing, toggling, swapping the display if user does some change in those plasma parameters. c. lastly it finalizes the event when user hits the OK button or CANCEL button. *Cartoon plug-in code review *1. first it creates two structures a. cvals (of CartoonVals ), with mask radious, threshold and percentage black b. PLUG_IN_INFO (of GimpPlugInInfo) 2. function 1: static void cartoon (GimpDrawable *drawable,GimpPreview *preview) a. it checks for the preview option, alpha channel in the given image. b. it also initializes two destination image structure, one for blur radius 1 and another for given mask radius. c. then it calculates the standard deviations from blur radius & mask radious and derives constants from them for calculating the gaussian values. d. then it starts computing pixel values first by vertically then by horizontally. e. for vertical case, for each vertical strip it initializes the process by dealing with the first and last points of the strip. f. after calculation with the help of those pre calculated gaussians consatnts, it transfers those calculated pixel values to their destination images. g. similarly it does for the horizontal case. h. then it computes ramp value (for percentage black) by calling the compute_ramp function. i. then it initializes the procedure for each pixel regions of the image by calculating the relative intensity difference= avg pixel intensity of 1st image(blur radious) / avg pixel intensity of 2nd image(mask radius) j. from this relative difference it calculates the intensity multiplication factor. if relative diff < Threshold, intensity mult = (Ramp - MIN (Ramp, (Threshold - relative diff))) / Ramp else mult =1.0 k. in the mean time it clamps the value of the lightness of the final image between 0 to 255. l. then it computes the pixel intensity and finalizes the destination image, but in this case, before writing pixel values to the destination image, it converts the color code first from rgb to hsl, then sets the lightness, and converts it back to rgb. 3. function 2: static gdouble compute_ramp (guchar *dest1,guchar *dest2,gint length,gdouble pct,gint under_threshold) a. it calculates the ramp value via hysterisis. b. fistly it calculates the difference between the pixel values of the two different destination images and hysterizes it. c. lastly with the obtained hysterized values it compares the percentage black value and determined the relative intensity. 4. function 3: static void find_constants (gdouble n_p[],gdouble n_m[],gdouble d_p[],gdouble d_m[],gdouble bd_p[],gdouble bd_m[],gdouble std_dev) a. it calculates some constants reqiures for 4th order approximation of the gaussian operator. 5. Main function a. it fetches the image first. b. then it checks for the run mode, if it's interactive then it starts with the default data, else it takes data from user. c. after that it calls the cartoon function, in the mean time it also keep flushing the display if run mode is non- interactive. 6. static gboolean photocopy_dialog (GimpDrawable *drawable) a. it opens up a dialogue box for cartoonization and sets it's parameters. b. it keeps on changing, swapping the display if user does some change in those cartoonizing parameters. c. lastly it finalizes the event when user hits the OK button or CANCEL button. *Photocopy plug-in code review *1. first it creates two structures a. pvals (of PhotocopyVals ), which includes properties of the final image like, sharpness, threshold, % black & % white b. PLUG_IN_INFO (of GimpPlugInInfo) 2. function 1: static void photocopy (GimpDrawable *drawable,GimpPreview *preview) a. it checks for the preview option, alpha channel in the given image. b. it also initializes two destination image structure, one for blur radius 1 and another for given mask radius. c. then it calculates the standard deviations from blur radius & mask radious and derives constants from them for calculating the gaussian values. d. then it starts computing pixel values first by vertically then by horizontally. e. for vertical case, for each vertical strip it initializes the process by dealing with the first and last points of the strip. f. after calculation with the help of those pre calculated gaussians consatnts, it transfers those calculated pixel values to their destination images. g. similarly it does for the horizontal case. h. then it computes ramp values ( ramp down for percentage black & ramp up for percentage white) by calling the compute_ramp function. i. then it initializes the procedure for each pixel regions of the image by calculating the relative intensity difference= avg pixel intensity of 1st image(blur radious) / avg pixel intensity of 2nd image(mask radius) j. from this relative difference it calculates the intensity multiplication factor. if relative diff < Threshold, intensity mult = (Ramp_down - MIN (Ramp_down, (Threshold - relative diff))) / Ramp_down else mult = MIN (Ramp_up,(diff - Threshold)) / Ramp_up; k. in the mean time it clamps the value of the lightness of the final image between 0 to 255. l. then it computes the pixel intensity and finalizes the destination image. 3. function 2: static gdouble compute_ramp (guchar *dest1,guchar *dest2,gint length,gdouble pct,gint under_threshold) a. it calculates the ramp value via hysterisis. b. fistly it calculates the difference between the pixel values of the two different destination images and hysterizes it. c. lastly with the obtained hysterized values it compares the percentage black / white value and determined the relative intensity. 4. function 3: static void find_constants (gdouble n_p[],gdouble n_m[],gdouble d_p[],gdouble d_m[],gdouble bd_p[],gdouble bd_m[],gdouble std_dev) a. it calculates some constants reqiures for 4th order approximation of the gaussian operator. 5. Main function a. it fetches the image first. b. then it checks for the run mode, if it's interactive then it starts with the default data, else it takes data from user. c. after that it calls the photocopy function, in the mean time it also keep flushing the display if run mode is non- interactive. 6. static gboolean photocopy_dialog (GimpDrawable *drawable) a. it opens up a dialogue box for photocopy and sets it's parameters. b. it keeps on changing, swapping the display if user does some change in those photocopy parameters. c. lastly it finalizes the event when user hits the OK button or CANCEL button. kindly have a look and let me know if there is any mistake. -- Sourav De 2nd Year Student Department of Computer Science and Engineering IIT KHARAGPUR
_______________________________________________ Gimp-developer mailing list Gimp-developer@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer