3 Replies Latest reply on Aug 21, 2013 8:42 AM by Mattmcquiff

    Find Visual Centre of a layer

    Mattmcquiff Level 1

      Not sure if this is possible, maybe with some maths? So possibly via applescript.


      I have a layer that is this is neck piece that you see, and you can see that the extension change makes the centre, 'off centre' or at least visually?


      How might I achieve this?


      I need to expand the canvas afterwards to create a border where the image is framed correctly as part of an automation.

      Screen shot 2013-08-21 at 15.57.00.png

        • 1. Re: Find Visual Centre of a layer
          c.pfaffenbichler Level 9

          So possibly via applescript.

          You may want to check over in the Photoshop Scripting Forum


          but I guess most of the regulars don’t bother much with AppleScript.

          By which I do not mean that AppleScript is bad, but it has no relevance for Windows users so the more popluar language for Photoshop Scripting is JavaScript.

          • 2. Re: Find Visual Centre of a layer
            Mylenium Most Valuable Participant

            AFAIK that's stuff only filters can do. One would probably sample columns/ rows or randomly angled lines and process their histogram to find the middle between some "peaks". Averaging multiple such results would then provide a center point. Additional processing could also eliminate any appendages that would skew the result. Of course this could be amped up indefinitely e.g. by calculating the gradinet vectors based on thresholds and finding the center that is farthest away from any "edges" or detecting the densest samples in DCT transforms or whatever. A million ways to go about this, but definitely beyond simple scripting or actions.



            • 3. Re: Find Visual Centre of a layer
              Mattmcquiff Level 1

              the nearest I think I could get,

              Copy to clipboard the entire layer


              Crop the vertical by half, with anchor point bottom centre,

              Trim based on transparent pixels

              From this you should have the centre point of the bottom half of the image, then some how replace from the infomation in the clipboard.....