Patent Document ID: 20160350940
Application ID: 15116647
Patent Status: 0

Claim One:
1. An automatic recognition and calibration method of medical color and grayscale images, which takes different calibration methods based on different image color attributes wherein comprising the steps as follows: step 1. according to component values of three channels R, G, B of each pixel of an original image, using the relationship of YUV and RGB color space to establish correspondence between the brightness and the three color components R, G, B, and expressing the corresponding pixel gray value with brightness, thereby forming the grayscale image; step 2. setting a global threshold T, and comparing each pixel gray value of the grayscale image with T, if the gray value being greater than T, then taking the foreground color of the pixel, otherwise taking the background color of the pixel to form the binary image; step 3. scanning line by line, detecting and counting pixels of the binary image, if the consecutive occurrences of the pixel having gray scale value of 255 being greater than a preset segment threshold, then judging it as a line segment and keeping it in a new image A; and then scanning the binary image column by column, detecting and counting pixels, if the consecutive occurrences of the pixel having gray scale value of 255 being greater than the preset segment threshold, then judging it as a line segment and keeping it in the image A, and finally, merging pixels of adjacent line segments respectively on the horizontal direction and vertical direction in the image A; step 4. creating a new image named B, in which an original rectangle with the original length of a and the width of b in image B is drawn; step 5. making the upper left corner of image A correspond to the upper left corner of the rectangular in the image B, denoted as (x1, y1), increasing the length of a and the width of b continuously, when the length increasing to a′ and the width increasing to b′, the pixel grayscale value of coordinate (x1+a′, y1+b′) in image A being 255, judging whether the grayscale values of three coordinates (x1+a′+1, y1), (x1, y1+b′+1), (x1+a′+1, y1+b′+1) being all 255, and if all of them being not 255, recording the current value of a′ as width, b′ as height, coordinate (x1+a′, y1+b′) as (xn, yn), and a′ and b′ being restored to the initial values of a and b; step 6. making the upper left corner of image A correspond to the upper left corner of the rectangular in the image B, denoted as (x1, y1), increasing the length of a and the width of b continuously, when the length increasing to a0 and the width increasing to b0, and the pixel grayscale value of coordinate (x1+a0, y1+b0) in image A being 255, judging whether the grayscale values of the pixels between coordinates (x1, y1+b0) and (x1+a0−1, y1+b0) being all 255, and whether the grayscale values of the pixels between coordinates (x1+a0, y1) and (x1+a0, y1+b0−1) being all 255; when the two conditions above being satisfied, then stopping to increase the values of a0 and b0, and recording the current value of a0 as w, b0 as h; if any one of the two conditions being not satisfied, recording the current coordinate values (x1+a0, y1+b0) as (x1_1, y1_1), and restoring a0 and b0 to initial values of a and b; making coordinate (x1_1, y1_1) in image A correspond to the upper left corner of the rectangular, then again using the above method to scan the image, getting the length a1 and width b1, and recording the value of a1 as w, b1 as h; step 7. using width/w, x1 and xn to determine the set of coordinates in the X direction as X_coord: (x1, x2,. .. , xp) (p is the number of the image fields in the X direction); and using height/h, y1 and yn to determine the set of coordinates in the Y direction as Y_coord: (y1, y2,. .. , yq) (q is the number of the image fields in Y direction); meanwhile traversing X_coord and Y_coord to obtain set of coordinates of starting coordinates and ending coordinates as Coord: {(xi,yj), (xi+1,yj+1)|1<=i<p and 1<=j<q}; step 8. determining images within the starting coordinate and ending coordinate in each of the image fields obtained above as grayscale image or color image; randomly sampling pixels in the image fields, sampling number being k; if the ratio of the total number of color pixels relative to its effective pixels being less than a ratio threshold, determining this image to be a grayscale image, and otherwise determining to be a color image; step 9. calibrating image fields determined as grayscale images by the corresponding DICOM3.14 calibration curve, and calibrating the above fields determined as color images by the corresponding GAMMA calibration curve.