Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Sunday, May 14, 2006 10:04:52 PM(UTC)

Amit  
Amit

Groups: Registered
Posts: 101


I am using Visual Basic 6 with LEAD Tools 14

I want the subtract background effect.  I tried the SubtractBackground function in lead, tried seting its parameters in many ways.  It is not giving me expected results.  It affects image quality.

I tried using Digital Subtraction, but it actually inverse the image.

I also tried low level programming.  Read the RGB value for first pixed (The background pixel).  Search for the value all over the image.  If found, replace it with white.  But the same pixel value may found in image itself.  So again, image quality disturb.

Second solution is, to trim the interested area of image.  But again, how to identify interested area of image.  the actual image size may differ.

I am attaching an image herewith.  Image contains scanned film with the whitish background.

I want all the whitish background replaced to perfectly white without touching image.  Actual film in the image should not change at any cost.

Waiting for your reply.

File Attachment(s):
SampleImage.JPG (784kb) downloaded 34 time(s).
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Wednesday, May 17, 2006 4:28:34 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

Was thanked: 1 time(s) in 1 post(s)

Hello,

To subtract the background of the image, you need to do the following:
1. Call the EdgeDetectEffect method (ILEADRasterProcess) as follows:
+---------------------------+
RasterProc.EdgeDetectEffect LEADRasterView1.Raster, 50, 0, EDGE_SOLID
+---------------------------+

2. Call the SetRgnMagicWand method (ILEADRaster)
+---------------------------+
LEADRasterView1.Raster.SetRgnMagicWand 0, 0, 10, L_RGN_SETNOT
+---------------------------+

3. Call the Fill method (ILEADRasterProcess) to fill the region with white:
+---------------------------+
RasterProc.Fill LEADRasterView1.Raster, RGB(255, 255, 255)
+---------------------------+

4. Now, keep this result image (with the region) and reopen the original image on a different viewer:
5. Now, you need to combine the result image with the original image using the CombineExt method (ILEADRasterProcess) as follows (The original image is the source image, and the result image (with region) is the destination image):
+---------------------------+
RasterProc.CombineExt
LEADRasterView1.Raster, DstLeft, DstTop, DstWidth, DstHeight, LEADRasterView2.Raster, SrcLeft, SrcTop, CB_OP_ADD
+---------------------------+

Please check the above instructions and let me know how it goes.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#3 Posted : Sunday, May 21, 2006 10:31:15 PM(UTC)

Amit  
Amit

Groups: Registered
Posts: 101


Thanks Maen,

I tried your logic.  It is not working in desired manner.

I remind you, I am using Visual Basic 6 with LT 14

'-----------------CODE-------------------------------------------------------------------------

Option Explicit
Dim rasterIO As LEADRasterIO
Dim rasterProc As leadRasterProcess

Private Sub Form_Load()
    Set rasterIO = New LEADRasterIO
    Set rasterProc = New leadRasterProcess
    cmdLoad_Click
End Sub

Private Sub cmdLoad_Click()
    leadRasterMain.Raster.Bitmap = 0
    rasterIO.Load leadRasterMain.Raster, App.Path & "\ExtraImages\DSCN0007.JPG", 0, 0, 1
    leadRasterProcess.Raster.Bitmap = leadRasterMain.Raster.Bitmap
End Sub

Private Sub cmdSubtract_Click()
    rasterProc.EdgeDetectEffect leadRasterMain.Raster, 50, 0, EDGE_SOLID
    'leadRasterMain.Raster.SetRgnMagicWand 0, 0, RGB(255, 255, 255), RGB(0, 0, 0), L_RGN_SETNOT
    leadRasterMain.Raster.SetRgnMagicWand 0, 0, 0, 10, L_RGN_SETNOT
    rasterProc.Fill leadRasterMain.Raster, RGB(255, 255, 255)
    rasterProc.CombineExt leadRasterMain.Raster, _
                          leadRasterMain.DstLeft, leadRasterMain.DstTop, _
                          leadRasterMain.DstWidth, leadRasterMain.DstHeight, _
                          leadRasterProcess.Raster, _
                          leadRasterProcess.SrcLeft, _
                          leadRasterProcess.SrcTop, CB_OP_ADD
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Set rasterIO = Nothing
    Set rasterProc = Nothing
End Sub

'-----------------END CODE-------------------------------------------------------------------

On my machine, leadtools asks for two extra parameters crLowerTolerence and crUpperTolerence with databype OLE_COLOR.

You can see those two extra parameters to SetRgnMagicWand method bold, underlined and in brown color in above code.  I tried many combinations of these parameters.  Am I setting those parameters wrong ?

When I run above code, instead of turning background to white, it is turning actual image area to white (and background to black).

My request is Copy above code to your project, Make necessary changes, Incluse corrected code in my reply.

Waiting for reply.

Thanks

 
#4 Posted : Tuesday, May 23, 2006 10:02:26 PM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

Was thanked: 1 time(s) in 1 post(s)

Hello,

I am attaching a small VB 6.0 project that shows how to subtract the background from an image (the background of the image will be white).

Please check the project and let me know if this helps.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
File Attachment(s):
COMv145.zip (766kb) downloaded 36 time(s).
 
#5 Posted : Tuesday, May 23, 2006 11:38:46 PM(UTC)

Amit  
Amit

Groups: Registered
Posts: 101


Hi Maen, Thousands of Thanks for the great solution

The sample you have send is working fine with the image I was attached in my first post.  Many thanks for that again.

Now I want to use the same ligic for the SonoGraphy Images.  I tried it, but it has three problems as stated bellow.  I have attached two images herewith.

Download same project you have send me in previous post.
Just replace the images I am sending herewith with SampleImage.jpg in folder.
Test the project.

You will observe three problems
1)  Text on the image become unreadable.
2)  Some of the image area also become white.
3)  Nothing Happens.

You can control problem 1) and 2) by setting "lLevel" parameter of EdgeDetectEffect method.
But it donot work much better (upto the satisfactory level).

I am working on these problems on my end.
I request you if you have any solution for this, please reply.

Waiting for reply.

File Attachment(s):
SampleImage.zip (217kb) downloaded 38 time(s).
 
#6 Posted : Sunday, May 28, 2006 6:04:11 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

Was thanked: 1 time(s) in 1 post(s)

Hello,

The problems that you face depend on the EdgeDetectEffect method and the values that you pass to the method (lLevel and lThreshold parameters). You may try to use the following values:
+--------------------------------------+
RasterPorc.EdgeDetectEffect LEADRasterView1.Raster, 79, 0, EDGE_SOLID
...
+--------------------------------------+

However, can you please provide me with more details about the 3rd problem (Nothing Happens)?

Thanks,
Maen Badwan
 
#7 Posted : Sunday, May 28, 2006 6:04:50 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

Was thanked: 1 time(s) in 1 post(s)

Hello,

The problems that you face depend on the EdgeDetectEffect method and the values that you pass to the method (lLevel and lThreshold parameters). You may try to use the following values:
+--------------------------------------+
RasterPorc.EdgeDetectEffect LEADRasterView1.Raster, 79, 0, EDGE_SOLID
...
+--------------------------------------+

However, can you please provide me with more details about the 3rd problem (Nothing Happens)?

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#8 Posted : Tuesday, May 30, 2006 5:48:04 AM(UTC)

Amit  
Amit

Groups: Registered
Posts: 101


Thanks Maen, Thousands of thanks

What I did is, I just provided sliders to set the values of necessary parameters.

And now, I can check any number of combinations for the effect.  The solution is working on various combination of parameters for different images.

Thanks again

Bye.

 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.295 seconds.