find the position of the last pixel in the image

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
conjure
Pro Scripter
Posts: 63
Joined: Thu Jan 12, 2012 3:05 pm

find the position of the last pixel in the image

Post by conjure » Sun May 29, 2016 4:57 pm

Hi.
I want to find the position of the last red or green pixel in the image i attached, to be able to know if the chart is going up or down.(The last position is on the right)
Is it possible?

hagchr
Automation Wizard
Posts: 327
Joined: Mon Jul 05, 2010 7:53 am
Location: Stockholm, Sweden

Re: find the position of the last pixel in the image

Post by hagchr » Sun May 29, 2016 7:01 pm

Hi, one approach could be to define a rectangle from the top to the bottom of the chart and let it be narrow eg 5 pixels. Then you start from the right side of the chart and loop to the left and in each iteration use GetRectCheckSum> to check if there is any change in the rectangle. Once it changes then you know you are at the time of the last point. Next step is to use the found rectangle, and loop from the top to the bottom and use eg GetRectCheckSum>, GetPixelColor>, ColorToRGB> to identify the height of the curve(s). (You need to take the 2 red guide lines into considerations but you know where they are and the colors are likely constant). Let's see if there are any other suggestions.

User avatar
JRL
Automation Wizard
Posts: 3497
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: find the position of the last pixel in the image

Post by JRL » Tue May 31, 2016 2:35 am

Perfect application for the one pixel BMP file subroutine that I posted in scripts and tips a few months ago. Use the subroutine with FindImagePos>. The last position found will be the last position of the last pixel in your chart. FindImagePos> searches and reports by column from top to bottom then from left to right. So Using:

FindImagePos>Needle.bmp,SCREEN,0,1,XArr,YArr,NumFound,EXACT

And since the chart's last position IS on the right the last position of the chart will be:

Sub>NumFound,1
Let>LastXpos=XArr_%NumFound%
Let>LastYpos=YArr_%NumFound%

Simply compare the last postion over time to see if the charts results are rising (Y decreasing) or falling (Y increasing).

Be sure to use EXACT to report all occurrences of the Needle.bmp. And you probably want to search only the window that contains the chart rather than the entire screen.

conjure
Pro Scripter
Posts: 63
Joined: Thu Jan 12, 2012 3:05 pm

Re: find the position of the last pixel in the image

Post by conjure » Thu Jun 02, 2016 6:57 pm

i found an easy way.. on my script it starts scanning from right to left until pixel found
Thank you for your help

Code: Select all

let>x=1750
label>start2
ScreenCapture>%x%,896,1795,1780,%TEMP_DIR%\screenrect.bmp
FindImagePos>Z:\%ppc%\red_1.bmp,%TEMP_DIR%\screenrect.bmp,0,1,XArr,YArr,NumFound
If>NumFound>0
let>red=YArr_0
else
let>x=%x%-1
goto>start2
Endif



Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts