Method and system for detecting position of internal slice of scanner

文档序号:635419 发布日期:2021-05-11 浏览:4次 中文

阅读说明:本技术 一种用于扫描仪内部切片位置检测的方法和系统 (Method and system for detecting position of internal slice of scanner ) 是由 刘炳宪 谢菊元 王焱辉 王克惠 丁科迪 于 2020-12-28 设计创作,主要内容包括:本发明一种用于扫描仪内部切片位置检测的方法和系统,拍摄加载有切片的预览图像进行灰度化,对灰度图像中在第一方向上的像素的灰度值进行累加得到第一数组,计算所有第一数组中第m个数的数值与第m+a个数的数值的第一差值,筛选出最大值所对应的m的取值p,获取灰度图像中在第二方向上所有第n条像素中第p-b至p+b个像素的灰度值的集合,计算所有第q个像素的灰度值与第q+1个像素的灰度值之间的第二差值,筛选最大值所对应的q的取值t,将第二方向上的第t个像素在灰度图像中的坐标值组合成一像素位置集合,对像素位置集合中的所有坐标值进行线性拟合,得到一直线,便于对切片的精确定位,提高工作效率和准确性,降低成本。(The invention relates to a method and a system for detecting the position of a slice in a scanner, which are used for shooting a preview image loaded with the slice to carry out graying, accumulating the gray values of pixels in the gray image in a first direction to obtain a first array, calculating a first difference value of the m-th number of numerical values and the m + a-th number of numerical values in all the first array, screening out the value p of m corresponding to the maximum value, obtaining a gray value set of p-b to p + b pixels in all the n-th pixels in a second direction in the gray image, calculating a second difference value between the gray values of all the q-th pixels and the gray value of the q + 1-th pixel, screening the value t of q corresponding to the maximum value, combining the coordinate values of the t-th pixels in the second direction in the gray image into a pixel position set, and carrying out linear fitting on all the coordinate values in the pixel position set, the straight line is obtained, so that the slicing can be accurately positioned conveniently, the working efficiency and the accuracy are improved, and the cost is reduced.)

1. A method for intra-scanner slice position detection, comprising the steps of:

a step a1 of taking a preview image loaded with a slice using a scanner;

step A2, performing gray scale conversion on the preview image to form a gray scale image, wherein the pixels of the gray scale image are a determinant matrix and are provided with M pixel groups in a first direction and N pixel groups in a second direction;

step a3, accumulating the gray values of the pixels in each pixel group in the gray image in the first direction to obtain a first array with a length M in the second direction;

step A4, calculating a first difference value between the number of the mth number and the number of the M + a number in all the first arrays, wherein the value of M is an integer from 1 to M-a, and a is a positive integer smaller than M;

step A5, screening out the value of m corresponding to the maximum value in all the first difference values, and recording the value as p;

step A6, acquiring a set of gray values of p-b to p + b pixels in all nth pixels in the gray image in the second direction to form a second array, wherein the value of N is an integer from 1 to N, and b is an integer greater than or equal to 1;

step A7, for each of the pixel groups in the second direction, calculating a second difference between the grayscale values of all the q-th pixels and the grayscale value of the q + 1-th pixel, where the value of q is from p-b to p + b-1;

step S8, for each pixel group in the second direction, screening out a value of q corresponding to a maximum value in the second difference value, and recording the value as t, and combining coordinate values of the t-th pixel of each pixel group in the second direction in the grayscale image into a pixel position set;

and step S9, performing linear fitting on all coordinate values in the pixel position set to obtain a straight line for positioning the slice.

2. The method for scanner interior slice position detection as claimed in claim 1, further comprising a step B1 between said step A3 and said step a 4: and normalizing the gray value of the pixel in the first array.

3. The method as claimed in claim 1, wherein the first direction is a Y direction, the second direction is an X direction, and the step S9 is performed to calculate a distance between the straight line obtained by linear fitting and a right boundary of the preview image as an offset in the X direction.

4. The method as claimed in claim 1, wherein the first direction is an X direction, the second direction is a Y direction, and the step S9 is performed to calculate a distance between the straight line obtained by linear fitting and a lower boundary of the preview image as an amount of shift in the Y direction.

5. The method as claimed in claim 1, wherein a is 10.

6. A method for intra-scanner slice position detection as claimed in claim 1, wherein b has a value of 5.

7. A system for detecting the position of a slice inside a scanner, which is applied to the method for detecting the position of a slice inside a scanner according to any one of claims 1 to 6, comprising:

a scanner for photographing the preview image loaded with the slice;

the gray processing module is connected with the scanner and is used for carrying out gray conversion on the preview image to form a gray image, wherein the pixels of the gray image are in a determinant matrix and are provided with M pixel groups in a first direction and N pixel groups in a second direction;

the accumulation module is connected with the gray processing module and used for accumulating the gray values of the pixels in each pixel group in the gray image in the first direction to obtain a first array with the length being the length M in the second direction;

the first difference value calculating module is connected with the accumulating module and used for calculating a first difference value between the mth number value and the M + a number value in all the first arrays, wherein the value of M is an integer from 1 to M-a, and a is a positive integer smaller than M;

the first screening module is connected with the first difference value calculating module and used for screening out the value of m corresponding to the maximum value in all the first difference values and marking the value as p;

the data extraction module is connected with the first screening module and used for acquiring a set of gray values of p-b to p + b pixels in all nth pixels in the gray image in the second direction to form a second array, wherein the value of N is an integer from 1 to N, and b is an integer greater than or equal to 1;

the second difference calculation module is connected with the data extraction module and used for calculating a second difference between the gray value of all the q-th pixels and the gray value of the q + 1-th pixels for each pixel group in the second direction, wherein the value of q is from p-b to p + b-1;

a second screening module, connected to the second difference value calculating module, configured to screen out, for each pixel group in the second direction, a value of q corresponding to a maximum value in the second difference value, which is denoted as t, and combine coordinate values of the t-th pixel in the grayscale image of each pixel group in the second direction into a pixel position set;

and the fitting module is connected with the second screening module and used for performing linear fitting on all coordinate values in the pixel position set to obtain a straight line so as to be used for positioning the slice.

8. The system of claim 7, further comprising a normalization module, respectively coupled to the accumulation module and the first difference calculation module, for further normalizing the values of the first array prior to calculating the first difference.

9. The system of claim 7, further comprising an offset calculation module connected to the fitting module for calculating a distance between the straight line obtained by linear fitting and the right boundary of the preview image as an offset amount in the X direction when the first direction is the Y direction and the second direction is the X direction, and for calculating a distance between the straight line obtained by linear fitting and the lower boundary of the preview image as an offset amount in the Y direction when the first direction is the X direction and the second direction is the Y direction.

10. The system of claim 7, wherein a is 10 and b is 5.

Technical Field

The invention relates to the technical field of biological slice image processing, in particular to a method and a system for detecting the position of a slice in a scanner.

Background

With the rise of pathological section scanners, more and more hospitals use pathological section scanners to obtain digital sections for convenient storage and browsing. In some special cases, when the doctor needs to go under the microscope again to review some fields of vision when browsing the digital section, the coordinate mapping between the scanner and the microscope is needed. It is common practice to have a standard positioning slice, and after positioning under the scanner preview camera and on the microscope, the corresponding coordinate map can be calculated. However, on a high-throughput scanner, since the position of the slice loaded onto the platform is not consistent every time, there is a certain deviation in the previously calculated coordinate mapping relationship, which eventually results in that the target field of view cannot be found under the mirror.

Disclosure of Invention

The invention provides a method and a system for detecting the position of a slice in a scanner, and aims to solve the technical problems that in the prior art, the coordinate mapping between the scanner and a microscope has deviation and the like due to the fact that the loading position of the slice is unstable.

A method for scanner internal slice position detection, comprising the steps of:

a step a1 of taking a preview image loaded with a slice using a scanner;

step A2, converting the gray scale of the preview image to form a gray scale image, wherein the pixels of the gray scale image are determinant matrixes and are provided with M pixel groups in a first direction and N pixel groups in a second direction;

step A3, accumulating the gray values of the pixels in each pixel group in the gray image in the first direction to obtain a first array with the length being the length M in the second direction;

step A4, calculating a first difference value between the number of the mth number and the number of the M + a number in all the first arrays, wherein the value of M is an integer from 1 to M-a, and a is a positive integer smaller than M;

step A5, screening out the value of m corresponding to the maximum value in all the first difference values, and marking as p;

step A6, acquiring a set of gray values of p-b to p + b pixels in all nth pixels in the gray image in the second direction to form a second array, wherein the value of N is an integer from 1 to N, and b is an integer greater than or equal to 1;

step A7, for each pixel group in the second direction, calculating a second difference value between the gray value of all the q-th pixels and the gray value of the q + 1-th pixels, wherein the value of q is from p-b to p + b-1;

step S8, for each pixel group in the second direction, screening out a value of q corresponding to a maximum value in the second difference value, and recording the value as t, and combining coordinate values of the t-th pixel of each pixel group in the second direction in the grayscale image into a pixel position set;

step S9, perform linear fitting on all coordinate values in the pixel position set to obtain a straight line for positioning the slice.

Further, a step B1 is included between the step A3 and the step a 4: and normalizing the gray values of the pixels in the first array.

Further, the first direction is the Y direction, the second direction is the X direction, and in step S9, the distance between the straight line obtained by the linear fitting and the right boundary of the preview image is calculated as the amount of shift in the X direction.

Further, the first direction is the X direction, the second direction is the Y direction, and in step S9, the distance between the straight line obtained by the linear fitting and the lower boundary of the preview image is calculated as the amount of shift in the Y direction.

Further, a takes a value of 10.

Further, b is 5.

A system for detecting the position of a slice inside a scanner, which applies the method for detecting the position of a slice inside a scanner, comprising:

a scanner for photographing the preview image loaded with the slice;

the gray processing module is connected with the scanner and is used for carrying out gray conversion on the preview image to form a gray image, wherein the pixels of the gray image are determinant matrixes and are provided with M pixel groups in the first direction and N pixel groups in the second direction;

the accumulation module is connected with the gray processing module and is used for accumulating the gray values of the pixels in each pixel group in the gray image in the first direction to obtain a first array with the length being the length M in the second direction;

the first difference value calculating module is connected with the accumulating module and is used for calculating first difference values of the number M and the number M + a in all the first arrays, wherein the value of M is an integer from 1 to M-a, and a is a positive integer smaller than M;

the first screening module is connected with the first difference value calculating module and used for screening out a value of m corresponding to the maximum value in all the first difference values and marking the value as p;

the data extraction module is connected with the first screening module and used for acquiring a set of gray values of p-b to p + b pixels in all nth pixels in the gray image in the second direction to form a second array, wherein the value of N is an integer from 1 to N, and b is an integer greater than or equal to 1;

the second difference value calculating module is connected with the data extracting module and used for calculating a second difference value between the gray value of all the q-th pixels and the gray value of the q + 1-th pixel for each pixel group in the second direction, wherein the value of q is from p-b to p + b-1;

the second screening module is connected with the second difference value calculating module and used for screening out a value of q corresponding to the maximum value in the second difference value for each pixel group in the second direction, marking the value as t, and combining coordinate values of the t-th pixel of each pixel group in the second direction in the gray level image into a pixel position set;

and the fitting module is connected with the second screening module and used for performing linear fitting on all coordinate values in the pixel position set to obtain a straight line so as to be used for positioning the slices.

The device further comprises a normalization module which is respectively connected with the accumulation module and the first difference value calculation module and is used for normalizing the numerical value of the first array before calculating the first difference value.

The image preview module is used for obtaining a preview image of a user, and the image preview module is used for obtaining a first direction and a second direction of the preview image, and the first direction is a Y direction and the second direction is a X direction.

Further, a takes a value of 10, and b takes a value of 5.

The beneficial technical effects of the invention are as follows: the method and the system of the invention process the image, firstly obtain the offset of the image in the X and Y directions, are convenient for accurately positioning the slice, improve the working efficiency and the accuracy and reduce the cost.

Drawings

FIG. 1 is a flow chart of the steps of a method for scanner internal slice position detection in accordance with the present invention;

FIG. 2 is a block schematic diagram of a system for intra-scanner slice position detection;

FIG. 3 is a block diagram of another embodiment of a system for intra-scanner slice position detection;

fig. 4 is a block diagram of another embodiment of a system for intra-scanner slice position detection.

Detailed Description

The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

It should be noted that the embodiments and features of the embodiments may be combined with each other without conflict.

The invention is further described with reference to the following drawings and specific examples, which are not intended to be limiting.

Referring to fig. 1, the present invention provides a method for detecting the position of a slice inside a scanner, comprising the steps of:

a step a1 of taking a preview image loaded with a slice using a scanner;

step A2, converting the gray scale of the preview image to form a gray scale image, wherein the pixels of the gray scale image are determinant matrixes and are provided with M pixel groups in a first direction and N pixel groups in a second direction;

step A3, accumulating the gray values of the pixels in each pixel group in the gray image in the first direction to obtain a first array with the length being the length M in the second direction;

step A4, calculating a first difference value between the number of the mth number and the number of the M + a number in all the first arrays, wherein the value of M is an integer from 1 to M-a, and a is a positive integer smaller than M;

step A5, screening out the value of m corresponding to the maximum value in all the first difference values, and marking as p;

step A6, acquiring a set of gray values of p-b to p + b pixels in all nth pixels in the gray image in the second direction to form a second array, wherein the value of N is an integer from 1 to N, and b is an integer greater than or equal to 1;

step A7, for each pixel group in the second direction, calculating a second difference value between the gray value of all the q-th pixels and the gray value of the q + 1-th pixels, wherein the value of q is from p-b to p + b-1;

step S8, for each pixel group in the second direction, screening out a value of q corresponding to a maximum value in the second difference value, and recording the value as t, and combining coordinate values of the t-th pixel of each pixel group in the second direction in the grayscale image into a pixel position set;

step S9, perform linear fitting on all coordinate values in the pixel position set to obtain a straight line for positioning the slice.

Further, a step B1 is included between the step A3 and the step a 4: and normalizing the gray values of the pixels in the first array.

Further, the first direction is the Y direction, the second direction is the X direction, and in step S9, the distance between the straight line obtained by the linear fitting and the right boundary of the preview image is calculated as the amount of shift in the X direction.

Further, the first direction is the X direction, the second direction is the Y direction, and in step S9, the distance between the straight line obtained by the linear fitting and the lower boundary of the preview image is calculated as the amount of shift in the Y direction.

Further, a takes a value of 10.

Further, b is 5.

Specifically, the technical solution of the present invention is specifically described by taking the example of calculating the offset in the X direction, where the X direction is a row direction, the Y direction is a column direction, and in step a2, after the gray-scale image is converted into the gray-scale image, the gray-scale image has M columns of pixels (M pixel groups) and N rows of pixels (N pixel groups), and the pixels in each column of the M columns are respectively accumulated to obtain a first array with a length of M, and there is only one row. And normalizing the first array to 0-1. After the first array is normalized, a first difference value between the number value of the mth number and the number value of the m +10 th number in the first array is calculated, and the m with the largest first difference value is found out and used as the position point p. Then, for each row of pixels in the gray-scale image, finding out a set of gray-scale values of all pixels from the p-5 th to the p +5 th columns, forming a second array, for each row of pixels in the gray-scale image, finding out a position point with the largest difference between two adjacent numbers in the second array, namely the largest second difference, and recording the coordinate of the point in the gray-scale image into a set, namely a pixel position set, so that at least one point is found out for each row in the gray-scale image, linear fitting is carried out to obtain a straight line y which is ax + b, and the distance d from the straight line to the right boundary of the image is calculated, namely the offset in the x direction.

Referring to fig. 2-4, a system for detecting the position of a slice inside a scanner, applied to the method for detecting the position of a slice inside a scanner, includes:

a scanner (1) for taking a preview image loaded with slices;

the gray processing module (2) is connected with the scanner (1) and is used for carrying out gray conversion on the preview image to form a gray image, wherein the pixels of the gray image are in a determinant matrix and are provided with M pixel groups in the first direction and N pixel groups in the second direction;

the accumulation module (3) is connected with the gray processing module (2) and is used for accumulating the gray values of the pixels in each pixel group in the gray image in the first direction to obtain a first array with the length being the length M in the second direction;

the first difference value calculating module (4) is connected with the accumulating module (3) and is used for calculating a first difference value between the number of the mth number and the number of the M + a number in all the first arrays, wherein the value of M is an integer from 1 to M-a, and a is a positive integer smaller than M;

the first screening module (5) is connected with the first difference value calculating module (4) and is used for screening out the value of m corresponding to the maximum value in all the first difference values and marking the value as p;

the data extraction module (6) is connected with the first screening module (5) and is used for acquiring a set of gray values of p-b to p + b pixels in all nth pixels in the gray image in the second direction to form a second array, wherein the value of N is an integer from 1 to N, and b is an integer greater than or equal to 1;

the second difference value calculating module (7) is connected with the data extracting module (6) and is used for calculating a second difference value between the gray value of all the q-th pixels and the gray value of the q + 1-th pixel for each pixel group in the second direction, wherein the value of q is from p-b to p + b-1;

the second screening module (8) is connected with the second difference value calculating module (7) and is used for screening out the value of q corresponding to the maximum value in the second difference value for each pixel group in the second direction, marking the value as t, and combining the coordinate values of the t-th pixel of each pixel group in the second direction in the gray level image into a pixel position set;

and the fitting module (9) is connected with the second screening module (8) and is used for performing linear fitting on all coordinate values in the pixel position set to obtain a straight line for positioning the slice.

Furthermore, the device also comprises a normalization module (10) which is respectively connected with the accumulation module (3) and the first difference value calculation module (4) and is used for normalizing the numerical values of the first array before calculating the first difference value.

Further, the image display device further comprises a deviation calculating module (11) which is connected with the fitting module (9) and used for calculating the distance between the straight line obtained through linear fitting and the right boundary of the preview image as the deviation amount in the X direction when the first direction is the Y direction and the second direction is the X direction, and calculating the distance between the straight line obtained through linear fitting and the lower boundary of the preview image as the deviation amount in the Y direction when the first direction is the X direction and the second direction is the Y direction.

Further, a takes a value of 10, and b takes a value of 5.

While the invention has been described with reference to a preferred embodiment, it will be understood by those skilled in the art that various changes in form and detail may be made therein without departing from the spirit and scope of the invention.

11页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:智能驾驶车辆的检测方法、控制方法和处理器

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!