I wrote the code review for 2 more plug-ins: Cartoon and Photocopy Gimp dialog function do all almost the same thing: Let the user choose the parameters for each plugin by opening a box with a preview box. While changing the parameters it changes the preview image until the user press the ok or the cancel button. We can say the same thing for run function (almost the same). It gets the drawable in the drawable structure the sets the tile cache size, gets data from the keyboard and run the dialog, if there is no dialog it initiates its own values for the plug-in. Checks if everything is all right, run the plugin and stores the data.

## Advertising

1. Cartoon (in gegl the base class would be AREA FILTER): Algorithm: For each pixel it calculates the pixel intensity by comparing the pixels relative intesity to its neighborhood pixels and to the relative intensity difference to total black . Let say mask radius is equal with radius of pixel neighborhood for intensity comparison, threshold is the relative intensity difference which will result in darkening, ramp is the amount of relative intensity difference before total black and blur radius is mask radius per 3. Then the new intensity of the pixel will be: relative difference = pixel intensity / average (mask radius) If relative difference < Threshold intensity multiply = (Ramp - MIN (Ramp, (Threshold - relative difference))) / Ramp pixel intensity =old intensity * intensity mult static void cartoon: Checks for the preview, then sets the width and height of the drawable image, gets the image type (bytes) and the aplha value (has_alpha). It initialize the 5 vectors and 2 destination image structures (dest1 for blur radius and dest2 for mask radius). Calculates the standard deviations from blur and mask radius. Then derives the constant values for calculating the gaussian's from the deviations (via the 4th order approximation of the gaussian operator). Like in the case of gaussian blur the calculation of the new values of the image is linear so the calculation can be devided for 2 directions. First calculates the values for every column then for every row. Calculating for every column: firstly initializes and calculates the first and the last pixel of the column. Then with the help of the gaussian constants it calculates every pixel of the column the transfers the pixels to the destination image. It will do the same calculations in case of the horizontal direction. After calculating the blakc percentage value (ramp). Then calculates the new intensity for each pixel: relative difference = pixel intensity / average (mask radius) intensity multiply=1 If relative difference < Threshold intensity multiply = (Ramp - MIN (Ramp, (Threshold - relative difference))) / Ramp pixel intensity =old intensity * intensity multiply Before upgrading the drawable image transfers the calculated destination image structure from RGB format to HLS, sets the lightness and converts back. computer ramp: Calculates the ramp value (intensity difference from total black) by calculating the difference between the destination images (one calculated with blur radius the other with mask radius), and hysterizes the difference. Then compares the hysterized values to the percentage of the black color and calculates the relative intensity via average. 2. Photocopy (in gegl the base class would be AREA FILTER): Propagates dark value in an image based on each pixel's relative darkness to a neighboring average. Sets the remaining pixels to white. The plug-in differs a little from the cartoon plug-in. Algorithm: Using the same notations as in the cartoon plug-in the new intensity of every pixel will be: elative diff = pixel intensity / avg (mask radius) If relative diff < Threshold intensity mult = (Ramp - MIN (Ramp, (Threshold - relative diff))) / Ramp pixel intensity *= intensity mult Else pixel intensity = white static void photocopy: It is almost the same as in the cartoon plug-in. Desaturates the image, checks for the preview, then sets the width and height of the drawable image, gets the image type (bytes) and the aplha value (has_alpha). It initialize the 5 vectors and 2 destination image structures (dest1 for blur radius and dest2 for mask radius). Calculates the standard deviations from blur and mask radius. Then derives the constant values for calculating the gaussian's from the deviations (via the 4th order approximation of the gaussian operator). Like in the case of gaussian blur the calculation of the new values of the image is linear so the calculation can be devided for 2 directions. First calculates the values for every column then for every row. Calculating for every column: firstly initializes and calculates the first and the last pixel of the column. Then with the help of the gaussian constants it calculates every pixel of the column the transfers the pixels to the destination image. It will do the same calculations in case of the horizontal direction. After calculating the black and white percentage values (ramp down and ramp up). Relative difference is equal with the average pixel intensity of the blur radius image per the average pixel intersity of the maske radius image. While calculating the intensity of each pixel it also calculates the lightness of the drawable image between 0 and 255. intensity multiply = 1 if relative diff < Threshold if ramp_down == 0 intensity multiply = 0 else intensity mult = (ramp_down - MIN (ramp_down, (Threshold - relative difference))) / ramp_down else if ramp_down !=0 mult = MIN (ramp_up,(relative difference - Threshold)) / ramp_up; Knowing the lightness calculates the value of each pixel and draws the image. compute ramp and find constants functions are the same as in the cartoon plug-in. Compute ramp and find constants could be directly written in gegl api as not to write the same thing twice. For recalculating the pixels by adding lightness we could use a lightness plug-in for it. I have an exam saturday, so I will finish and send the plug-in ported to gegl on sunday. If there is anything else I should do please write it. If there is something wrong with the code reviews tell it and I will rewrite it. Thanks, Robert Sasu

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