Automating bucket fill actions on transparent layer in GIMP - gimp

Using GIMP, I am attempting to generate a large number of the same image but with different colors. In order to preserve the "shadowing", I am using the below steps. These steps get me exactly what I want in the end. The problem is, it's very tedious repeating them by hand over and over. There has to be a better way.
GIMP's batch scripting seems a little daunting, so I'm hoping to get some suggestions on how to automate this. Basically, what would be nice, is I'd like to essentially specify an array or list of colors...and then "automagically" perform the steps below to generate the output with the desired color.
Steps I'm doing by hand...
1.) Load a base PNG file that has an alpha channel.
2.) Add a new transparent layer.
3.) Activate the layer.
4.) Change mode to "multiply".
Then, for a range of different colors, I do the following...
5.) Select a foreground color.
6.) Apply bucket fill (fill similar colors, fill transparent areas, default threshold, fill by composite).
7.) Save the new PNG.
8.) Go to Step #5.
Here's kind of a cheesy representation of the effect I'm trying to achieve...
I'm also open to other non-GIMP suggestions as well.
Thanks for any and all help and suggestions.

I can offer you a nice Javascript example that do this.
try:
https://stackoverflow.com/a/9304367/1726419
there is a link there that actually do what you wand in JS - you can translate it to many other languages...

Related

replacing an existing color by a new one in an image with iOS

Let's say I have an image with a few colors.
I would like to replace programmatically a specific existing color by a new one.
(something simple, no need to support gradients, like I saw elsewhere).
E.g. I have an image showing a green circle and I want to display it as a red circle (every pixel initially defined with a given (R,G,B) is now displayed with a new (R,G,B).
Any idea of how to do that with the Apple ios SDK ? (or open source ...)
And btw what would be the best image file format to make this easier (png, jpg ....) ?
Thanks !
You should be able to do this using Core Image filters. the Color Cube CI filter lets you map a source color range to destination colors. You should be able to define a source color range and map it to different colors.
That's one CI Filter I didn't figure out how to use however. If you do a search on "Color Cube" in the Xcode help system there is sample code that does a "chromakey" effect that knocks out green shades to transparent. You should be able to adapt that to your needs.
I have a project on Github called CIFilterTest that shows how to use Core Image filters to process images. It's written as a general-purpose system that lets you try a wide variety of filters that use a standard set of parameters (points, colors, 1 or 2 source images, and floating-point values.) I never did take the time to generate the 3D color mapping "cube" that the color cube filter needs as input, so it doesn't allow you to use that particular filter. You'll have to look at the color Cube sample code in the Xcode docs to generate inputs for the Color Cube filter, but my sample app should help a great deal with the basic setup for doing CI based image processing.
answered similar question here:
Replace particular color of image in iOS
in short: I would suggest using CoreImage filter.

Project ideation using image processing

I am in my final year of BS Computer Science. I have chosen a project in the image processing domain. But I really don't know where to start from! Here is a rough draft of my project idea:
Project Description:
Often people are faced with the problem of deciding which colors to choose to paint their walls, doors and ceilings. They want to know how their rooms will look like after applying a certain color. We want to design a mobile application that can give people the opportunity to preview their rooms/walls/ceilings, etc, with a certain color before applying the color. Through our application the user can take photos of their rooms/walls/ceilings, etc, and change their colors virtually and preview them. This will give them a good estimate about the final look of their house.
Development will be in java using open CV libraries.
Can anyone provide some help?
For starting OpenCV with android you can follow the tutorial here.
And as your above description, I think you need to do the following...
Filter out the color of room's wall or ceiling color.
Replace with your preview color.
But as your room's color is not unique, you may need to mark the color manually and segment it. Here watershed algorithm might be helpful.
And one more thing is that there might be a chance of lighting variation, so you should use HSV color space instead of RGB.
And finally this is not the full solution, but you will get some idea about how to start with your project.
ImageMagick as a famous image processing library.You may look that one too.It can perform numerous operations with images
Thanks

Clojure GUI for cropping images

I'm making a GUI for selecting regions to crop from images. I have been using Seesaw and cans select rectangular regions, but cannot find a way to set an image to the background of seesaw.canvas. This suggests using icons on labels. Can I make a label paintable and then use it as a canvas? Is there a way to overlap a label and a canvas or somehow use a panel that gives a background to its contents?
I think Quil has this functionality, but I'm not sure how to build a GUI around its draw, setup, sketch form if I want add widgets.
Existing solutions would appreciated as well, as long as I can decompose them. Using GIMP or Photoshop isn't an option for the workflow I want: multiple crops per photo, of different kinds on each page and different metadata added depending on the type of image outlined. Any suggestions for libraries for working with metadata for photos? I was planning on using a shell interface to exiftool, but a more portable option may be better.
You can draw a java.awt.Image (or sub-class) to a canvas with seesaw.graphics/image-shape:
(require '[seesaw.graphics :as g])
(defn paint-canvas [c g2d]
(g/draw g2d (g/image-shape my-image 0 0) (g/style)))
It seems like that should do it.
Also note that labels (and all Seesaw widgets) are paintable. Just set the :paint option like on a canvas and paint away.

Replace particular color of image in iOS

I want to replace the particular color of an image with other user selected color. While replacing color of image, I want to maintain the gradient effect of that original color. for example see the attached images.
I have tried to do so with CoreGraphics & I got success to replace color. But the replacing color do not maintain the gradient effect of the original color in the image.
Can someone help me on this? Is the CoreGraphics is right way to do this?
Thanks in advance.
After some struggling almost with the same problem (but with NSImage), made a category for replacing colors in NSImage which uses ColorCube CIFilter.
https://github.com/braginets/NSImage-replace-color
inspired by this code for UIImage (also uses CIColorCube):
https://github.com/vhbit/ColorCubeSample
I do a lot of color transfer/blend/replacement/swapping between images in my projects and have found the following publications very useful, both by Erik Reinhard:
Color Transfer Between Images
Real-Time Color Blending of Rendered and Captured Video
Unfortunately I can't post any source code (or images) right now because the results are being submitted to an upcoming conference, but I have implemented variations of the above algorithms with very pleasing results. I'm sure with some tweaks (and a bit of patience) you might be able to get what you're after!
EDIT:
Furthermore, the real challenge will lie in separating the different picture elements (e.g. isolating the wall). This is not unlike Photoshop's magic wand tool which obviously requires a lot of processing power and complex algorithms (and is still not perfect).

Getting the average color of frames in a video

End goal: Get the average colour of each frame in a video.
My plan so far is this:
Export the frames of the video as individual images.
Batch process the images to resize them as 1px x 1px as I believe this will provide the average colour.
Get the RGB value of that one pixel and record it as text.
Where I'm stuck is step 3. I've no idea how one would go about this programmatically.
I only need to do this once or twice, so it doesn't need to be completely automatic, I'm just keen to avoid copy pasting colour values manually.
EDIT: The first two steps don't require any programming so I am pretty open to using whatever language your solution requires. My forte is PHP, and this is for an Arduino project, so C-like languages are fine, but whatever will get the job done. I use a Mac but Windows or Linux also not a problem either.
Since you are doing something with image processing, I assume you are doing this in matlab.
So you can read the image first:
A = imread('filename.jpg');
To get the Red color you can use:
A(1,1,1);
To get Green and Blue just change the index to 2 and 3 respectively in the third column.

Resources