getProfile() function not following the scale

Tags: #<Tag:0x00007fd548d32be0> #<Tag:0x00007fd548d31a10> #<Tag:0x00007fd548d310d8>



I noticed that when I use the macro to plot the profile (ie. profile = getProfile();, the x-axis does not follow the scale I set. The plot should look like when I click on Analyze > Plot Profile. Does the function getProfile() only plot using the pixel scale? Is it possible to use that function and make it follow the scale I set? Thanks in advance.

> macro "LineWidth [2]"{
profile =getProfile();   
   Plot.create("Detecting Minima", "X", "Y", profile);;
minLocs= Array.findMinima(profile, 20);
   for (jj= 0; jj < minLocs.length; jj++){
      x= minLocs[jj];
      y = profile[ x ];
      print("x= ", x, " y= ", y);
      toUnscaled(x, y);
run ("Select None");

PS. I select a region in the image, then run the macro.

plot using getProfile():

plot using Analyze > Plot Profile :


Hey @limellama -

Seems strange. For me I get the same output using your macro versus Analyze > Plot Profile on just a simple square ROI on a built-in sample image (Blobs). Perhaps you can attach your dataset so we can test it out on your same exact image?

What version of ImageJ/Fiji are you running?



Good day!

Here is an adapted version of your macro that works for me:

img = getImageID;
profile = getProfile();
x = Array.getSequence( profile.length );
scaleArray( img, x )
Plot.create( "Detecting Minima", "X", "Y", x, profile );;
minLocs = Array.findMinima( profile, 20 );
Array.sort( minLocs );
minPos = Array.copy( minLocs );
scaleArray( img, minLocs ); minLocs );
print( "\\Clear" );
for ( i = 0; i < minLocs.length; i++ ) {
      x = minLocs[i];
      y = profile[ minPos[i] ];
      print( "x= ", x, " y= ", y );
      toUnscaled( x, y );
      makeOval( x-4, y-4, 8, 8 );
      run( "Invert" );
run( "Select None" );
function scaleArray( image, array ) {
	front = getImageID;
	selectImage( image );
	for ( i= 0; i < array.length; i++ ) toScaled( array[i] );
	selectImage( front );

I must admit it isn’t very elegant …




Hello @etarena,

I am currently using ImageJ 1.51s. Since the desktop I’m using is macOS High Sierra (v. 10.13.3), I had to download ImageJ bundled with Java 1.8.0_101 version. Anyway, below is the image that I am trying to process:


Thank you for your help again, @Herbie! Your script works for now.


In general @limellama … we recommend downloading/using Fiji.

Fiji is Just ImageJ - it is simply a distribution of ImageJ that comes with a bunch of plugins bundled - ready for you to use out-of-the-box. And it’s easily updatable - which is handy as well.

eta :slight_smile: