Let's analyze it first:
(The following values, how to obtain them, and then analyze them in the specific implementation. Now we will only talk about macro-level values)
How do I obtain the image information of the selected domain?In fact, how do we obtain the selected area, the position in the image, and the size of this area?
Tell the computer the location and size, and it will know that we are going to get the image information.
(Our selection area is in a plane and is a regular image, square, or both rectangular (common: rectangle ))
Size:
The width and height of the area. The two values are multiplied by the area, that is, the size of the area. (This should not be difficult)
Location:
1. if we only tell the computer that the selected region has a [coordinate value of the starting point] and the computer's [area], there are four conditions that match the two conditions:
"Red" indicates the starting point coordinate of the selected region;
A, B, C, and D are the selected regions starting from red (the area of each region is the same, and the coordinates of the start point are the same, but four situations can be found );
1. Suppose we tell the computer that the two coordinate values of the selected region also tell the computer area:
"Red" indicates the starting point coordinate of the selected region,
"Blue" is the coordinate value of the horizontal end point of the selected area.
"Green" indicates the area of the selected area;
Only one of the three conditions must be met.
Therefore, we need to obtain the region information of this image.
The preceding three values: Two-Point coordinate value and one area value.
$ ('# X1'). Val (selection. X1 );
$ ('# Y1'). Val (selection. Y1 );
$ ('# X2'). Val (selection. x2 );
$ ('# Y2'). Val (selection. Y2 );
$ ('# W'). Val (selection. width );
$ ('# H'). Val (selection. Height );