Solved

HARD!! getting/changing data in bitmap image

Posted on 2003-10-21
13
239 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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
 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

821 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