Line detection on noisy image

Hello everyone,

Could someone give me a direction to segment the line that crosses the image. I’ve tried some tools like TWS and Ridge detection with no significant results. The noise in the image is an atribute from the material (granite) so growing image quality won’t help. My goal is to automatically identify other lines like this in other images.
Sem%20t%C3%ADtulo

Threshold the image, apply Hough transform and locate the maximum to identify the line.

I used ImageMagick Hough line detector:

convert image.jpg -negate -threshold 30%                 \
    \( +clone -background none                           \
              -fill red -stroke red -strokewidth 2       \
              -hough-lines 5x5+220 -write lines.mvg      \
    \) -composite lines.png

A text file (lines.mvg) is also created with the lines found:

# Hough line transform: 5x5+220
viewbox 0 0 821 567
line 0,564.638 821,-124.263  # 249

Hi Andrei,

I too found it hard to find a Hough line transform for imageJ. However, there is a Radon transform plugin and the two are very closely related.

There are some limitations with Radon transform in imageJ:

  • square images only
  • doesn’t automate easily with the macro recorder.

Here’s a square crop from image with a couple more lines drawn on it. The attached script produced the image.

-Chris

id_orig = getImageID();
recalc=true;
if( recalc ){
	run("Duplicate...", " ");
	id_tmp = getImageID();
	run("16-bit");
	run("Invert");
	getStatistics(area, mean, min, max, std, histogram);
	run("Subtract...", "value="+round(mean));
	run("RadonTransform ");
        // The users needs to press the button in the radon transform dialog
	waitForUser("press calculate\n");
	
	id_sine=getImageID();
	selectImage(id_tmp);
	close();
	selectImage(id_sine);

	run("Find Maxima...", "prominence=30 output=[Point Selection]");
	getSelectionCoordinates(xpoints, ypoints);
	ints=newArray(xpoints.length);
	for( i=0;i<xpoints.length;i++){
		ints[i] = getPixel(xpoints[i], ypoints[i]);
		
		print(xpoints[i],ypoints[i],ints[i]);
	}
}
getDimensions(ws, hs, channels, slices, frames);
selectImage(id_orig);
getDimensions(w, height, channels, slices, frames);


colors=newArray('red','orange','yellow','green','blue');
for(i=0;i<minOf(xpoints.length,colors.length);i++){
	mx = xpoints[i];
	my = ypoints[i];
	
	th=((mx)/(ws*1.)+0.5)*PI;
	R=-(my-hs/2.)/(hs/2.)*w/sqrt(2);
	
	xc=w/2.;
	yc = xc;

	makeLine(xc,yc,xc+R*sin(th),yc+R*cos(th),xc+R*sin(th)+ints[i]*sin(th+PI*0.5),yc+R*cos(th)+ints[i]*cos(th+PI*0.5));
	Overlay.addSelection(colors[i]);


}
Overlay.show;

Borja, Thank you very much for you answear, it helped a lot
I found a nice hough transform for image J: https://imagingbook.com/imagej-tutorial/
But it quantifies only in Log. My goal is automate the process by quantifing the consistency of the line (that could be done anilising the count statistics in the log). Any idea how can i proceed?
screenshot

Maybe use a macro to read log window content?