Skip to main content
Participant
December 27, 2011
質問

Automatic Detection of Scale Bar/Insert New Scale Bar

  • December 27, 2011
  • 返信数 2.
  • 1702 ビュー

Two quick questions.  I have never scripted much, but I have an idea which would help my workflow professionally. 

The first questions is whether there are any professional services which I might be able to contract in order to have a script developed? 

The second question is in regards to whether my scripting idea would even be possible in Photoshop. 

I do research using electron microscopes, and as such in every micrograph I collect there is a scale bar.  Unfortunately, the scale bars are not aesthetically pleasing, and so I bring them into Photoshop.  Typically I will rescale, cut, paste, etc to use the images to tell the story about the data.  One of the things I always do is draw a line trace over the scale bar on the image (typically with my own font and applied stroke) and then adjust it (whether I want to double the scale, etc) to make it look more professional.  On all of my micrographs there is a black information bar with white lettering and a white scale bar (see attached).  Is there any way to write a script that would automatically read the region where the scale bar is located and then draw a new layer with a line the same size (with the line properties desired) using a Fourier transform or some other mathematical algorithm?  If that is possible, the next step would be to read the scale bar size and do a similar function with inserted text.

Thanks,

Matt

このトピックへの返信は締め切られました。

返信数 2

c.pfaffenbichler
Community Expert
Community Expert
December 29, 2011

Have been approached by anyone of the pros yet?

If not it might be possible to get the size of the white rectangle from a Work Path.

Are the images all grayscale and is the whole bar always the same size and position?

olszta77作成者
Participant
December 29, 2011

No, you are the only response I have gotten thusfar.

I have never used Work Paths before, so I am not sure.

The images are grayscale, and the scale bar is always in the same position,

but not the same size (width wise). I take images at many differetn

magnifications, so each image could vary in the length of the scale bar.

Hence, each time I want to make a custom scale bar and cut off that black

banner at the bottom, I need to make a new layer by drawing a line matching

the scale.

Thanks

Matt

c.pfaffenbichler
Community Expert
Community Expert
December 31, 2011

OK, I was reading through the script you wrote, and I was curious how it

detects the exsiting scale bar? You are correct in that the length is the

only thing that changes. The width stays the same.

Thanks

Matt


The Script loads channels[0] as a selection (that’s the gray channel in a grayscale image) and intersects it with a rectangular selection as set in this line:

myDocument.selection.select([[0,960], [975,960], [975,992], [0,990]], SelectionType.INTERSECT, 0, false); 

If the whole thing at the bottom is always in the same position that should cover the white rectangle as it stretches from the left edge to a couple of pixels before the text.

So there is actually no real detection going on and it works only if the scale bar is at the expected position.

The resulting selection is then used to create a work path and this to create Solid Color Layer with a Vector Mask.

c.pfaffenbichler
Community Expert
Community Expert
December 28, 2011

The first questions is whether there are any professional services which I might be able to contract in order to have a script developed?

As far as I know some of the regulars in this Forum offer their services professionaly but you could also ask over at

http://ps-scripts.com/bb/