-
Apr 14th, 2014, 06:30 PM
#1
Thread Starter
New Member
Get X, Y of 1 pixel of a color in a image?
Hi all, I am currently making a little project [Image Find and replace] in which the user loads a image into the form, and selects a color from a combo box, And selects a new color to replace it with.
The problem I am facing is that I want to take the image supplied and find the color the user specified and get the X and the Y of 1 pixel in which contains that color [Plan to use a loop and loop through each pixel containing that color and draw over it with the other color.
Could anyone point me in the right direction to do so?
If some one could help me out I would be very grateful
-
Apr 15th, 2014, 03:55 AM
#2
Fanatic Member
Re: Get X, Y of 1 pixel of a color in a image?
God, are you punishing me because my hair is better than yours? -Jack Donaghy
-
Apr 18th, 2014, 10:57 AM
#3
Thread Starter
New Member
Re: Get X, Y of 1 pixel of a color in a image?
Unfortunately GetPixel requires a X, Y to go from in which would require scanning of the image, GetPixel is rather slow for that and would take up alot of CPU usage.
-
Apr 18th, 2014, 11:15 AM
#4
Re: Get X, Y of 1 pixel of a color in a image?
Originally Posted by Dragnite
Unfortunately GetPixel requires a X, Y to go from in which would require scanning of the image, GetPixel is rather slow for that and would take up alot of CPU usage.
If by "scanning" you mean looping through X and Y coordinates, I think that's what you will have to do. This makes it quite a bit faster though:
http://www.vbforums.com/showthread.p...hlight=fastpix
-
Apr 18th, 2014, 02:07 PM
#5
Re: Get X, Y of 1 pixel of a color in a image?
I figured that somebody would link to Boops^2 FastPix. It's some good stuff for this, and the thread is an entertaining introduction to Moti, too.
You will have to visit every pixel in the image to find all the pixels of that color. There's really no good, general-purpose, way around that. In some specific situations, you'd be able to build either a key or a mask that would speed up location of a color, but the situations where that would be useful would be VERY specific, and far more specific than the one you mention. You sound like you are doing general image processing on whatever image the user wants to deal with. Very few shortcuts would be available in such a situation. You could build an index of all the pixels in the image and use that as a fast way to change one color to another, but building the index would require visiting all the pixels, so it is only justified if you know that you will be swapping one color for another many times over without doing anything else that would invalidate the index. That seems unlikely.
My usual boring signature: Nothing
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|