Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to detect line scratches in image?

Posted on 2009-04-11
17
859 Views
Last Modified: 2013-11-23
Hi experts,

    I am working on borland delphi-7(pascal). Now I am working for detection of line scratches(ie verticle and horizontal lines defects)  from the image. From one of paper I got information that Luminance value will be very high or very low for the scratch as compared to their neighborhood. Now how can I detect line scratches  from the image.


   Thanking you in advance.
0
Comment
Question by:inampudi1
  • 10
  • 7
17 Comments
 
LVL 8

Expert Comment

by:BdLm
ID: 24121475

there are many algo so find scratches on images, basically the depend on what the scratch on your images is looking like,   eg.

a) your are sure the line has a different color, you may work with Threshold image procedures

b) if the line is just a significant change in the color value, you will work in the gradient domain of your image
0
 
LVL 8

Expert Comment

by:BdLm
ID: 24121493
some  basic info on image processing you will find here :  http://www.efg2.com/Lab/Library/Delphi/Graphics/ImageProcessing.htm


the gradient doimain topic:


Edeg detection:   http://en.wikipedia.org/wiki/Canny_edge_detector

if you need more basic info on image processing:  http://www.delphi-treff.de/tutorials/grafik-und-spiele/bitmaps/  (very good and easy to understand, but only german .-)  )
0
 

Author Comment

by:inampudi1
ID: 24121514
Hi experts,

Thank you for reply,
   I am  mainly working on black and white images. Please explain me in detail about


a) your are sure the line has a different color, you may work with Threshold image procedures

b) if the line is just a significant change in the color value, you will work in the gradient domain of your image


Thanking you.

0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 8

Expert Comment

by:BdLm
ID: 24121729
here comes a rather basic procedure template,
the treshold is 128 is values; you may set pixel data above threshold to eg. 0 and below to 255; pls. do some experiments byyour self.

can you attach one of your images ?  for pure black and white images both proposed alsgo won't work good. need one more math approach. (Hough Transformations)




procedure ProcessaImage(Bit: TBitmap);
type
  PixArray = array [1..3] of Byte;
  averagecolor  : interger;
var
  p: ^PixArray;
  h,w: Integer;
begin
  for h:=0 to Bit.Height-1 do
  begin
    p:= Bit.ScanLine[h];
    for w:=0 to Bit.Width-1 do
   
 
     begin
       averagecolor : =  (p^[1] + p^[2] + p^[3]); 
 
       if averagecolor < 128 do
               begin
                    p^[1] := ..... ;
                    p^[2] := ..... ;
                    ...
               end
               else
               begin
 
                    p^[1] := ..... ;
                    p^[2] := ..... ;
                    ...
 
 
 
               end;
 
      
      Inc(p);
     end;
  end;
end;

Open in new window

0
 

Author Comment

by:inampudi1
ID: 24121975
Hi experts,

  Pl find my image containing some vertical lines.


I will test the code you have given.
testimg.bmp
0
 

Author Comment

by:inampudi1
ID: 24122073
Hi BdLm,

   i checked your code but it is not detecting scratch. Even I checked with different values for FOR loop. Pl tell me how to change the code.
0
 
LVL 8

Expert Comment

by:BdLm
ID: 24122377
here come a sample image using the gradient methode,  f(x)  = df/dx + df/dy
can you code that and use only df/dx to focus on scratches ?

test-gradient
0
 
LVL 8

Expert Comment

by:BdLm
ID: 24122408
0
 
LVL 8

Expert Comment

by:BdLm
ID: 24122605
I played a bit with thresholding ->  no success

with gradient -> you will find the edges (but all horizontal and vertical) , see post above
here is the image again with extension

test-gradient.bmp
test-threshold.bmp
0
 

Author Comment

by:inampudi1
ID: 24124620
Hi Bdlm,
    I saw your images.But your algorithm  is detecting  some of the objects also as scratch , and some of lines are not detecting.  Please tell me any other algorithms.
0
 

Author Comment

by:inampudi1
ID: 24128848
Hi Bdlm,

     By using Hough_transform I tried, it is detecting lines fine, along with that, some of real part of image also detected as line, for ex pillers in a image and narrow roads in the image.

     How can I filter them.
0
 
LVL 8

Expert Comment

by:BdLm
ID: 24128850
the long wooden pales on your images own almost the same properties in the  pictures as your scratch,  you will need to implement a gradient algo first and then to a scond check of these data and scrren out if the scratch is a scratch or a wooden pale
0
 
LVL 8

Accepted Solution

by:
BdLm earned 500 total points
ID: 24128939
here comes an example for the color distribution, the pales and the scratches own almost the same size and gradient (df/dx), is this typical for all of your images?

pale-2.bmp
0
 
LVL 8

Expert Comment

by:BdLm
ID: 24128946
try to mesure the length of a horicontal line, that might be a good screening criteria.
0
 

Author Comment

by:inampudi1
ID: 24145879
Hi Bdlm,

  from color destribution graph how can I get the (how can I mark the)  lines in the image. Please  tell me.
0
 

Author Comment

by:inampudi1
ID: 24155329
Hi,
   

   Please tell me how Can I detect bloches,and dust in the image.


0
 
LVL 8

Expert Comment

by:BdLm
ID: 24155356

for dust (salt and pepper noise) I commend to use median filtering of your image,
 
see eg.  http://www.efg2.com/Lab/Library/Delphi/Graphics/ImageProcessing.htm
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Title # Comments Views Activity
Correct Component for Shopping Cart. 2 112
Adoquery sql  left join does not work 25 99
How to load 2 images in same column in Delphi 2 57
enhance the following code 3 37
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

828 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