Solved

HARD!! getting/changing data in bitmap image

Posted on 2003-10-21
13
235 Views
Last Modified: 2012-06-27
Hi experts,
     I have a question that should set you thinking.

     I have a bitmap(a picute I took with a digital camera) that has some writing on it, well its a picture of some writing.  The problem with the photo is that the background is a kind of yucky grey/brown colour, though i wrote it on a clean WHITE peice of paper.

I want to write a program that makes the background colour a colour of the users choice.

I don't even know where to start writeing this, can some one help?

thanx,
     Boyidiot
0
Comment
Question by:Boyidiot
  • 7
  • 4
  • 2
13 Comments
 

Assisted Solution

by:eliaslopezgtz
eliaslopezgtz earned 100 total points
ID: 9595227
try using the win32 api...
setpixel... getpixel...
that would be the fastest way to do ...
but you need to get used to handles.. and things like that...
0
 

Author Comment

by:Boyidiot
ID: 9595275
yes I could do that I could get the user to select the back colour on the picture then change/blankout all the pixels with that colour, but the background colour isn't the same colour.

hmmm, I could get the user to select the text colour(at its lightest), then only keep the pixels that are darker than it.

Could you help me put it into code, I dont know how to use Setpixel/getpixel.
thanx

 Boyidiot
0
 

Expert Comment

by:eliaslopezgtz
ID: 9595400
Public Declare Function ExtFloodFill Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long, ByVal wFillType As Long) As Long
Public Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Public Type POINTAPI
    x As Long
    y As Long
End Type

this are the declarations
let me write some samples wait a sec...
0
 

Expert Comment

by:eliaslopezgtz
ID: 9595408
Private Sub draw_MouseDown(button As Integer, Shift As Integer, x As Single, y As Single)
    If button = vbLeftButton Then draw.FillColor = col1.BackColor
    If button = vbRightButton Then draw.FillColor = col2.BackColor
    Dim m As POINTAPI
    m.x = x / 15
    m.y = y / 15
    p = GetPixel(draw.hdc, m.x, m.y)
    ExtFloodFill draw.hdc, m.x, m.y, p, 1
    draw.Refresh
end sub
0
 

Expert Comment

by:eliaslopezgtz
ID: 9595412
0
 
LVL 10

Accepted Solution

by:
cool12399 earned 100 total points
ID: 9600471
Also...

Just so you are aware -- the programming task will be a little more challenging than you think,
you will either need a little bit of mathematics background, or someone who does. The image
will not have a 'uniform' yellow color, so you will have to test for tolerance as well if you use
some kind of flood fill routine, which means you'll have to write your own routine to make it
look right. Otherwise -- what you'll see -- is basically an image, still with some yellow, and some
of the yellow pixels whited out. And you can't simply change all 'yellow' pixels, in case the 'image'
has yellow color in it...

So it'll be a little harder than you expect.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Boyidiot
ID: 9603734
thanx for the advice, I'm gonna make sure though that the write be in black/blue, a dark colour.

'you will either need a little bit of mathematics background'- How much?

0
 

Expert Comment

by:eliaslopezgtz
ID: 9607351
0
 

Expert Comment

by:eliaslopezgtz
ID: 9607388
or maybe if you want...
http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture04/

best regards and don't forget to accept an answer
0
 

Author Comment

by:Boyidiot
ID: 9609832
I wont forget, I'm just gonna give it another couple of days or so
0
 
LVL 10

Expert Comment

by:cool12399
ID: 9610148
how about giving me the points?? :)
now *theres* good advice!

to do it correctly (make it look good), you will either need a fair amount, or
hire someone skilled to do it. a simple flood fill will not work (will only do adjacent pixels
of the same color).

0
 

Expert Comment

by:eliaslopezgtz
ID: 9610380
you are right... help us please
0
 

Author Comment

by:Boyidiot
ID: 9620675
well I've done it, it just needs abit of tunig to get it perfect, but I DID IT!!!

heres how,

i've got two pictureboxes one with the picture in it. then the user selects a colour, It splits that colour into RGB, then the program gram goes through each pixel(about 10000 a second) and sees if its darker or lighter than the set colour. If it is darker it transfers it to the other picturebox.

well thanx guys
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now