Method and electronic device for realizing binary morphological operation based on memristor array
Through the storage and calculation integrated computing architecture based on the memristor array, the problem of low data access efficiency in image processing in the existing technology is solved, efficient binary morphological operations are achieved, and energy consumption is reduced.
Patent Information
- Application Number
- CN202011055269.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-29
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2040-09-29
AI Technical Summary
The existing morphological operation implementation platform consumes a lot of time and energy due to frequent data access processes in image processing, and it is difficult to efficiently implement binary morphological operations.
Adopting an integrated storage and calculation computing architecture based on memristor arrays, the memristor array stores binary image information to implement image expansion and erosion operations, and utilizes the parallel multiply-accumulate computing capabilities of the memristor array to efficiently complete binary morphological operations. .
It reduces data movement, improves the efficiency and speed of image morphology operations, reduces energy consumption, and achieves efficient binary morphology calculations.
Smart Images

Figure CN112150343B
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to a method and an electronic device for implementing binary morphological operations based on a memristor array. Background Art
[0002] Mathematical morphology has applications in aerospace, industrial production, medical imaging and other fields. Dilation, erosion, opening and closing operations, morphological gradients and particle analysis in binary morphological operations are important steps in image processing. Dilation and erosion, the most basic operations in morphology, are to find the local maximum or minimum after multiplying the image and the structural element. The calculation process is similar to the convolution operation. Summary of the invention
[0003] At least one embodiment of the present disclosure provides a method for implementing binary morphological operations based on a memristor array, wherein the memristor array includes a plurality of memristor units arranged in an array, including:
[0004] An image to be processed and a structural element for the binary morphological operation are obtained, wherein the image to be processed and the structural element are both binary images, and both include a plurality of pixels arranged in an array, and the value of each pixel is one of a first value and a second value different from each other, and the structural element includes an array origin; the value of each pixel in the image to be processed is mapped to a memristor unit corresponding to the memristor array; at least part of the pixels selected in the image to be processed are traversed in sequence using the structural element, and in the process of traversing the image to be processed, for each selected pixel, each selected pixel is aligned with the array origin in the structural element, the structural element defines a window area in the image to be processed, the structural element and the window area are multiplied and processed through the memristor array, and a corresponding binary morphological result is obtained according to the calculation result of the multiplication and processing and the type of the binary morphological operation, wherein the memristor array is configured to perform multiplication and sum operations.
[0005] For example, in the method provided by at least one embodiment of the present disclosure, the structural element includes m rows and n columns, m and n are positive integers respectively, and the structural element and the window area are multiplied and processed through the memristor array, including: for each of the m rows of the structural element, the n pixel points in each row are multiplied one by one with the n pixel points in the window area corresponding to each row according to the n positions in each row, to obtain n products corresponding to each row, thereby obtaining a total of m*n products for the m rows of the structural element, and the m*n products are summed to obtain the calculation result of the multiplication and sum processing.
[0006] For example, in the method provided by at least one embodiment of the present disclosure, the second value is used to identify the filled part in the binary image, and in response to the type of the binary morphological operation being a dilation operation and the calculation result of the multiplication and processing is greater than or equal to the second value, the corresponding binary morphological result is the second value, otherwise it is the first value; in response to the type of the binary morphological operation being an erosion operation and the calculation result of the multiplication and processing is equal to the number of pixel points in the structural element whose value is the second value, the corresponding binary morphological result is the second value, otherwise it is the first value.
[0007] For example, in the method provided by at least one embodiment of the present disclosure, the memristor array includes M rows and N columns, and the memristor array also includes M word lines, M source lines and N bit lines, the M word lines and the M source lines correspond to the M rows respectively, the N bit lines correspond to the N columns respectively, and M and N are positive integers; for each of the m rows of the structural element, the n pixel points in each row are multiplied one by one with the n pixel points in the window area corresponding to each row according to the n positions in each row to obtain the n products corresponding to each row, including: applying the start signal row by row to the positions in the window area corresponding to the A word line of a selected row corresponding to each row, wherein the turn-on signal is used to turn on a plurality of memristor units corresponding to the selected row; based on the values of the pixel points of each row in the structural element, input signals are applied to the bit lines of the memristor units corresponding to the positions of n pixel points of each row in the window area, respectively, wherein the input signals include a first input signal corresponding to the first value and a second input signal corresponding to the second value, and the first input signal is different from the second input signal; an output current signal on a source line in the selected row is obtained, wherein the output current signal corresponds to the n products corresponding to each row.
[0008] For example, in the method provided by at least one embodiment of the present disclosure, the memristor array includes M rows and N columns, and the memristor array also includes M word lines, M source lines and N bit lines, the M word lines and the M source lines correspond to the M rows respectively, the N bit lines correspond to the N columns respectively, M and N are positive integers, and the structural element has a symmetrical structure symmetrical with respect to the central axis along the row direction, wherein, for each of the m rows of the structural element, the n pixel points in each row are multiplied one by one with the n pixel points in a row corresponding to the window area according to the n positions in each row to obtain n products, including: in response to the i-th row of the structural element having a symmetrical j-th row, applying an on signal to the i-th row of the structural element and the j-th row of the structural element at the same time; The word line of the first selected row corresponding to the i-th row and the word line of the second selected row corresponding to the j-th row in the window area; based on the value of the pixel point of the i-th row or the j-th row, the input signal is applied to the bit lines of the memristor unit corresponding to the positions of n pixel points in the window area corresponding to the i-th row or the j-th row, respectively, wherein the input signal includes a first input signal corresponding to the first value and a second input signal corresponding to the second value; a first output current signal on the source line in the first selected row and a second output current signal on the source line in the second selected row are obtained, wherein the first output current signal corresponds to n products of the i-th row, and the second output current signal corresponds to n products of the j-th row.
[0009] For example, in the method provided in at least one embodiment of the present disclosure, the m*n products are summed to obtain the calculation result of the multiplication and sum processing, including: accumulating the m output current signals corresponding to the m rows of the structural element respectively to obtain a total output current signal, and the total output current signal corresponds to the calculation result of the multiplication and sum processing.
[0010] For example, in the method provided by at least one embodiment of the present disclosure, each of the multiple memristor units has a first state and a second state, the first state is different from the second state, and when each of the multiple memristor units is turned on by receiving the start signal applied by the corresponding word line and the second input signal is applied to the corresponding bit line to be read, in response to the first state, each of the multiple memristor units generates a first read current I1 on the corresponding source line, and in response to the second state, each of the multiple memristor units generates a second read current I2 on the corresponding source line. The corresponding binary morphological result is obtained according to the calculation result of the multiplication and sum processing and the type of the binary morphological operation, including: in response to the total output current signal being greater than the reference current, the corresponding binary morphological result is the second value, otherwise it is the first value; or the total output current signal is converted into a corresponding output voltage signal, in response to the output voltage signal corresponding to the total output current signal being greater than the reference voltage, the corresponding binary morphological result is the second value, otherwise it is the first value.
[0011] For example, in the method provided by at least one embodiment of the present disclosure, the first read current I1 is 0, in response to the binary morphological operation being an image corrosion operation, the reference current is I2*V, in response to the binary morphological operation being an image dilation operation, the reference current is I2, wherein V is the number of pixel points in the structural element whose value is the second value; and the reference voltage corresponds to the reference current.
[0012] For example, in the method provided by at least one embodiment of the present disclosure, at least part of the pixel points selected in the image to be processed are all the pixel points in the image to be processed, and the method also includes: arranging the binary morphological results of all the pixel points of the image to be processed according to the positions of all the pixel points in the image to be processed to obtain the binary morphological results of the image to be processed.
[0013] For example, in the method provided by at least one embodiment of the present disclosure, obtaining the image to be processed includes: dividing the initial image into regions to obtain a plurality of the images to be processed, and the method also includes: correspondingly splicing the binary morphological results of the plurality of images to be processed according to the positional relationship of the plurality of images to be processed in the initial image to obtain the binary morphological result of the initial image.
[0014] For example, in the method provided by at least one embodiment of the present disclosure, obtaining the image to be processed includes: obtaining an initial image and performing edge pixel expansion on the initial image to obtain the image to be processed.
[0015] For example, in the method provided by at least one embodiment of the present disclosure, the initial image has T rows and S columns, the initial image includes two side edges in the row direction and two side edges in the column direction, the structural element includes m rows and n columns, T, S, m and n are respectively positive integers, and the edge pixel point expansion of the acquired initial image includes: extending at least one side edge in the row direction of the initial image by a total of p pixels in a direction away from the initial image, wherein p is a positive integer and is less than or equal to m-1; and extending at least one side edge in the column direction of the initial image by a total of q pixels in a direction away from the initial image, wherein q is a positive integer and is less than or equal to n-1.
[0016] For example, in the method provided by at least one embodiment of the present disclosure, each of the multiple memristor units has a first state and a second state, and mapping the value of each pixel point in the image to be processed to the memristor unit corresponding to the memristor array includes: in response to the value of each pixel point in the image to be processed being the first value, setting the memristor unit at the position corresponding to each pixel point in the memristor array to the first state; in response to the value of each pixel point in the image to be processed being the second value, setting the memristor unit at the position corresponding to each pixel point in the memristor array to the second state, wherein the first state is different from the second state.
[0017] For example, in the method provided by at least one embodiment of the present disclosure, the structural element also includes a reference pixel point, and the corresponding binary morphological result is a binary morphological result of a pixel point at a position corresponding to the reference pixel point in the window area.
[0018] At least one embodiment of the present disclosure provides an electronic device, comprising: a memristor array, wherein the memristor array is configured to perform multiplication and sum operations; and a controller, wherein the controller is configured to perform the following steps: obtaining an image to be processed and a structural element used for the binary morphological operation, wherein the image to be processed and the structural element are both binary images, both comprising a plurality of pixels arranged in an array, the value of each pixel being one of a first value and a second value different from each other, and the structural element comprising an array origin; mapping the value of each pixel in the image to be processed to a memristor unit corresponding to the memristor array; using the structural element to sequentially traverse at least a portion of the pixels selected in the image to be processed, and in the process of traversing the image to be processed, for each selected pixel, aligning each selected pixel with the array origin in the structural element, the structural element defining a window area in the image to be processed, performing multiplication and sum processing on the structural element and the window area through the memristor array, and obtaining a corresponding binary morphological result according to the calculation result of the multiplication and sum processing and the type of the binary morphological operation.
[0019] For example, the electronic device provided in at least one embodiment of the present disclosure also includes a current detection module, wherein the current detection module includes an accumulation unit and a comparison unit; the accumulation unit is configured to collect and accumulate the output current signal of the source line of the memristor array to obtain a total output current signal; the comparison unit is configured to compare the total output signal with a reference current.
[0020] For example, the electronic device provided in at least one embodiment of the present disclosure also includes a current detection module, wherein the current detection module includes an accumulation unit and a comparison unit, the accumulation unit is an integrator, and the integrator is configured to convert the output current signal of the source line of the memristor array into a corresponding voltage signal and accumulate it to obtain an output voltage signal; the comparison unit is used to compare the magnitude relationship between the output voltage signal and the corresponding reference voltage signal obtained by the reference current passing through the integrator.
[0021] For example, in the electronic device provided in at least one embodiment of the present disclosure, the memristor array includes a plurality of memristor units arranged in an array, the memristor array includes M rows and N columns, the M word lines and the M source lines correspond to the M rows respectively, and the N bit lines correspond to the N columns respectively; the memristor unit is a 1T1R or 2T2R structure.
[0022] For example, the electronic device provided in at least one embodiment of the present disclosure also includes a source line driving circuit, configured to control the output signals of the M source lines of the memristor array; a word line driving circuit, configured to apply control signals to the M word lines of the memristor array respectively; and a bit line driving circuit, configured to apply input signals to the N bit lines of the memristor array. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings of the embodiments will be briefly introduced below. Obviously, the drawings in the following description only relate to some embodiments of the present disclosure, but are not intended to limit the present disclosure.
[0024] Figure 1 A schematic structural diagram of a memristor array provided for at least one embodiment of the present disclosure;
[0025] Figure 2A is a schematic diagram of a memristor unit having a 1T1R structure;
[0026] Figure 2B is a schematic diagram of a memristor unit having a 2T2R structure;
[0027] Figure 3A Schematic diagram of the image dilation process in binary morphological operation;
[0028] Figure 3B It is a schematic diagram of the image erosion process in binary morphological operation;
[0029] Figure 4 A schematic flow chart of a method for implementing binary morphological operations based on a memristor array according to at least one embodiment of the present disclosure;
[0030] Figure 5A A schematic diagram of an image to be processed and a structural element provided in at least one embodiment of the present disclosure;
[0031] Figure 5B A schematic diagram of a memristor array provided according to at least one embodiment of the present disclosure;
[0032] Fig. 6A A schematic diagram of a structure element in a binary morphological operation is provided for an embodiment of the present disclosure;
[0033] Figure 6B A schematic diagram of an initial image in a binary morphological operation is provided for an embodiment of the present disclosure;
[0034] Figure 6C A flow chart of a method for implementing binary morphological operations based on a memristor array provided in one embodiment of the present disclosure;
[0035] Fig.6D A schematic diagram of an initial image provided by an embodiment of the present disclosure;
[0036] Fig. 6E A schematic diagram of an image to be processed provided by an embodiment of the present disclosure;
[0037] Fig. 6F A schematic diagram of the principle of image binary morphological processing provided by an embodiment of the present disclosure;
[0038] Figure 6G A schematic diagram of a binary morphological processing process for an image provided by an embodiment of the present disclosure;
[0039] Figure 7 A schematic block diagram of an electronic device provided for at least one embodiment of the present disclosure. DETAILED DESCRIPTION
[0040] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution of the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings of the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the described embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0041] Unless otherwise defined, the technical terms or scientific terms used in the present disclosure should be understood by people with ordinary skills in the field to which the present disclosure belongs. The "first", "second" and similar words used in the present disclosure do not indicate any order, quantity or importance, but are only used to distinguish different components. "Include" or "comprise" and similar words mean that the elements or objects appearing before the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0042] In order to keep the following description of the embodiments of the present disclosure clear and concise, the present disclosure omits detailed descriptions of some known functions and known components.
[0043] The existing morphological operation implementation platforms, such as CPU or GPU, are all based on the traditional von Neumann architecture, where data and storage units are separated. During the operation, the pixel values of the image need to be frequently retrieved from the memory and sent to the processing unit for related calculations, and the calculation results also need to be returned to the memory for storage. The frequent data access process takes up most of the time and energy consumption.
[0044] Memristor (e.g., resistive random access memory, phase change memory, conductive bridge memory, etc.) is a non-volatile device whose conductivity state can be adjusted by applying external stimuli. As a two-terminal device, memristor has the characteristics of adjustable resistance and non-volatility, so it is widely used in storage and computing. According to Kirchhoff's current law and Ohm's law, an array composed of memristors can complete multiplication and accumulation calculations in parallel, and storage and calculation occur in each device in the array. Based on this computing architecture, storage and computing can be realized without the need for large amounts of data movement.
[0045] At present, crossbar arrays composed of memristors can complete matrix-vector multiplication operations in parallel and are widely used in accelerating neural network algorithms. Therefore, memristor arrays can be used to complete multiplication and calculations to realize binary morphological calculations.
[0046] A method for implementing a binary morphological operation based on a memristor array provided by an embodiment of the present disclosure includes: obtaining an image to be processed and a structural element used for the binary morphological operation, wherein the image to be processed and the structural element are both binary images, and both include a plurality of pixels arranged in an array, and the value of each pixel is one of a first value and a second value different from each other, and the structural element includes an array origin; mapping the value of each pixel in the image to be processed to a memristor unit corresponding to the memristor array; using the structural element to sequentially traverse at least part of the pixels of the image to be processed, and in the process of traversing the image to be processed, for each selected pixel, aligning each selected pixel with the array origin in the structural element, the structural element defines a window area in the image to be processed, performing multiplication and sum processing on the structural element and the window area through the memristor array, and obtaining a corresponding binary morphological result according to the calculation result of the multiplication and sum processing and the type of the binary morphological operation, wherein the memristor array is configured to perform multiplication and sum operations.
[0047] At least one embodiment of the present disclosure also provides an electronic device corresponding to the above-mentioned method for implementing binary morphological operations based on a memristor array.
[0048] The method for implementing binary morphological operations based on a memristor array provided in the above-mentioned embodiment of the present disclosure can store binary image information through a memristor array to implement image dilation and image erosion operations, and utilize the storage and computing advantages of the memristor array to efficiently and quickly implement image morphological operations.
[0049] The embodiments of the present disclosure are described in detail below with reference to the accompanying drawings, but the present disclosure is not limited to these specific embodiments.
[0050] Figure 1 The schematic structure of a memristor array is shown. The memristor array is composed of a plurality of memristor units, which form an array of m rows and n columns, where m and n are both positive integers. Each memristor unit includes a switch element and one or more memristors. Figure 1 In, WL <1> , WL <2> ...WL <m>BL represent the word lines of the first row, the second row, ... the mth row respectively, and the control electrode (eg, the gate of the transistor) of the switch element in the memristor unit circuit of each row is connected to the word line corresponding to the row; <1> BL <2> ...BL <n>They represent the bit lines of the first column, the second column, ... the nth column respectively, and the memristors in the memristor unit circuit of each column are connected to the bit lines corresponding to the column; SL <1> , SL <2> ...SL <m>The source lines of the first row, the second row, ... the nth row are represented respectively, and the source of the transistor in the memristor unit circuit of each row is connected to the source line corresponding to the row. According to Kirchhoff's law, by setting the state (e.g., resistance value) of the memristor unit and applying corresponding word line signals and bit line signals to the word line and bit line, the above memristor array can complete multiplication and accumulation calculations in parallel.
[0051] Figure 1 The memristor unit in the memristor array may be, for example, a 1T1R structure or a 2T2R structure, wherein the memristor unit of the 1T1R structure includes a transistor and a memristor, and the memristor unit of the 2T2R structure includes two transistors and two memristors.
[0052] It should be noted that the transistors used in the embodiments of the present disclosure may be thin film transistors or field effect transistors (such as MOS field effect transistors) or other switching devices with the same characteristics. The source and drain of the transistor used here may be symmetrical in structure, so the source and drain may be indistinguishable in structure. In the embodiments of the present disclosure, in order to distinguish the two poles (i.e., source and drain) of the transistor other than the gate, one of the poles is directly described as the first pole and the other pole is the second pole. The embodiments of the present disclosure do not limit the type of transistor used.
[0053] Figure 2A Schematic diagram of a 1T1R memristor unit. Figure 2A As shown, the memristor unit of the 1T1R structure includes a transistor M1 and a memristor R1.
[0054] For example, when the transistor M1 is an N-type transistor, its gate is connected to the word line terminal WL, for example, when a high level is input to the word line terminal WL, the transistor M1 is turned on; the first electrode of the transistor M1 can be a source electrode and is configured to be connected to the source line terminal SL, for example, the transistor M1 can receive a reset voltage through the source line terminal SL; the second electrode of the transistor M1 can be a drain electrode and is configured to be connected to the second electrode (for example, the negative electrode) of the memristor R1, and the first electrode (for example, the positive electrode) of the memristor R1 is connected to the bit line terminal BL, for example, the memristor R1 can receive a set voltage through the bit line terminal BL. For example, when the transistor M1 is a P-type transistor, its gate is connected to the word line terminal WL, for example, when the word line terminal WL is input with a low level, the transistor M1 is turned on; the first electrode of the transistor M1 can be a drain and is configured to be connected to the source line terminal SL, for example, the transistor M1 can receive a reset voltage through the source line terminal SL; the second electrode of the transistor M1 can be a source and is configured to be connected to the second electrode (for example, the negative electrode) of the memristor R1, and the first electrode (for example, the positive electrode) of the memristor R1 is connected to the bit line terminal BL, for example, the memristor R1 can receive a set voltage through the bit line terminal BL. It should be noted that the resistive memory structure can also be implemented as other structures, such as a structure in which the second electrode of the memristor R1 is connected to the source line terminal SL, and the embodiments of the present disclosure are not limited to this.
[0055] The following embodiments are described by taking the transistor M1 as an N-type transistor as an example.
[0056] The function of the word line terminal WL is to apply a corresponding voltage to the gate of the transistor M1, thereby controlling the transistor M1 to be turned on or off. When operating the memristor R1, such as performing a set operation or a reset operation, it is necessary to turn on the transistor M1 first, that is, it is necessary to apply a turn-on voltage to the gate of the transistor M1 through the word line terminal WL. After the transistor M1 is turned on, for example, a voltage can be applied to the memristor R1 at the source line terminal SL and the bit line terminal BL to change the resistance state of the memristor R1. For example, a set voltage can be applied through the bit line terminal BL to make the memristor R1 in a low resistance state; for another example, a reset voltage can be applied through the source line terminal SL to make the memristor R1 in a high resistance state. For example, the resistance value of the high resistance state is more than 100 times the resistance value of the low resistance state, for example, more than 1000 times.
[0057] It should be noted that, in the embodiment of the present disclosure, by applying voltage simultaneously to the word line terminal WL and the bit line terminal BL, the resistance value of the memristor R1 can be made smaller and smaller, that is, the memristor R1 changes from a high resistance state to a low resistance state, and the operation of changing the memristor R1 from a high resistance state to a low resistance state is called a set operation; by applying voltage simultaneously to the word line terminal WL and the source line terminal SL, the resistance value of the memristor R1 can be made larger and larger, that is, the memristor R1 changes from a low resistance state to a high resistance state, and the operation of changing the memristor R1 from a low resistance state to a high resistance state is called a reset operation. For example, the memristor R1 has a threshold voltage, and when the input voltage amplitude is less than the threshold voltage of the memristor R1, the resistance value (or conductance value) of the memristor R1 will not be changed. In this case, the resistance value (or conductance value) of the memristor R1 can be used for calculation by inputting a voltage less than the threshold voltage; the resistance value (or conductance value) of the memristor R1 can be changed by inputting a voltage greater than the threshold voltage.
[0058] Figure 2B Schematic diagram of a 2T2R memristor unit. Figure 2B As shown, the 2T2R structure memristor unit includes two transistors M1 and M2 and two memristors R1 and R2. The following description is made by taking the transistors M1 and M2 both being N-type transistors as an example.
[0059] The gate of transistor M1 is connected to the word line terminal WL1, for example, transistor M1 is turned on when a high level is input to the word line terminal WL1 of M1, and the gate of transistor M2 is connected to the word line terminal WL2, for example, transistor M2 is turned on when a high level is input to the word line terminal WL2 of M2; the first electrode of transistor M1 can be a source and is configured to be connected to the source line terminal SL, for example, transistor M1 can receive a reset voltage through the source line terminal SL, the first electrode of transistor M2 can be a source and is configured to be connected to the source line terminal SL, for example, transistor M2 can receive a reset voltage through the source line terminal SL, the first electrode of transistor M1 is connected to the first electrode of transistor M2, and they are connected together to the source line terminal SL. The second electrode of the transistor M1 may be a drain and configured to be connected to the second electrode (e.g., negative electrode) of the memristor R1, the first electrode (e.g., positive electrode) of the memristor R1 is connected to the bit line terminal BL1, for example, the memristor R1 may receive a set voltage through the bit line terminal BL1; the second electrode of the transistor M2 may be a drain and configured to be connected to the second electrode (e.g., negative electrode) of the memristor R2, the first electrode (e.g., positive electrode) of the memristor R2 is connected to the bit line terminal BL2, for example, the memristor R2 may receive a set voltage through the bit line terminal BL2.
[0060] It should be noted that the transistors M1 and M2 in the memristor unit of the 2T2R structure may also be P-type transistors, which will not be described in detail here.
[0061] The basic operations in binary morphological operations include image dilation and image erosion. Both dilation and erosion are used to eliminate noise in the image. The image is convolved through the structural element to obtain the local maximum or local minimum and assign the maximum or minimum to the specified pixel point to achieve noise processing of the image. Binary morphological operations also include opening and closing operations. The opening operation includes the process of first eroding and then dilating the image, which is mainly used to eliminate isolated points in the image that are smaller than the structural element and smooth the contour of the object; the closing operation includes the process of first dilating and then eroding the image, which is used to eliminate some small intervals and holes.
[0062] Figure 3A The figure is a schematic diagram of the image dilation process in the binary morphological operation. The left side is the image to be processed (A), the middle is the structural element (B), and the right side is the image obtained after the dilation process (C). The dilation operation can be expressed as shown in formula (1):
[0063]
[0064] For example, the image to be processed and the structural element are both binary images, and the value of each pixel is one of the first value and the second value. For example, the first value is 0 and corresponds to the white part in the binary image, for example, corresponding to 255 grayscale (that is, the selected grayscale range is 0 to 255), and the second value is 1 and corresponds to the black part in the image, for example, corresponding to 0 grayscale. For example, the second value is used to identify the filling part in the binary image, for example, Figure 3A The three black pixels of the structural element in are the filling part of the structural element. The structural element also includes the reference pixel, and the calculation result of the convolution operation is assigned to the pixel corresponding to the reference pixel in the image to be processed, that is, the pixel to be judged.
[0065] The image dilation process is similar to domain expansion. The structure element is convolved with the image to be processed. If the intersection of the filled part in the area covered by the structure element in the image to be processed and the filled part of the structure element is not empty, that is, the sum of the products of the values of the pixel points in the area covered by the structure element in the image to be processed and the corresponding position of the structure element is greater than or equal to the second value, then the binary morphological result of the judged pixel point corresponding to the reference pixel point in the covered area is the second value, otherwise the binary morphological result of the judged pixel point is the first value.
[0066] For example, when the structural element is moved to the position defined by the dotted box in the image to be processed, the sum of the products of the values of the pixels in the image to be processed in the dotted box and the corresponding position of the structural element is 1, which is equal to the second value. Then the binary morphological result of the pixel to be judged is the second value, such as Figure 3A The expanded pixels in the expanded image are shown as follows.
[0067] For example, the structural element is moved in the processed image with a step length of one pixel and the above convolution operation is performed to obtain the dilation result of each determined pixel, thereby obtaining Figure 3A The image after dilation shown on the right.
[0068] Figure 3B The figure is a schematic diagram of the binary morphological operation image erosion process. The left side is the image to be processed (A), the middle is the structure element (B), and the right side is the image after the erosion of the image to be processed by the structure element (C). The erosion operation can be expressed as shown in formula (2):
[0069]
[0070] The image erosion process is similar to the cannibalization of a domain. The structure element is convolved with the image to be processed. If the filling part of the structure element is included in the filling part of the area covered by the structure element in the image to be processed, that is, the sum of the products of the area covered by the structure element in the image to be processed and the values of the pixels at the corresponding positions of the structure element is greater than or equal to the number of pixels in the structure element whose pixel values are the second value, then the binary morphological result of the judged pixel corresponding to the reference pixel in the covered area is the second value, otherwise the binary morphological result of the judged pixel is the first value.
[0071] For example, when the structural element is moved to the position defined by the dotted box in the image to be processed, the sum of the products of the values of the pixels in the image to be processed in the dotted box and the corresponding position of the structural element is 2, which is less than the number of pixels in the structural element whose values are the second value, 3, then the binary morphological result of the pixel to be judged is the first value, such as Figure 3B The eroded pixels in the image after erosion processing are shown as follows.
[0072] For example, the structural element is moved in the processed image with a step length of one pixel and the above convolution operation is performed to obtain the corrosion result of each determined pixel, thereby obtaining Figure 3B The image after corrosion processing is shown on the right side of the figure.
[0073] Figure 4 A schematic flow chart of a method for implementing binary morphological operations based on a memristor array according to at least one embodiment of the present disclosure is provided.
[0074] For example, Figure 4 As shown, the method for implementing binary morphological operation based on a memristor array provided by the embodiment of the present disclosure includes steps S110 to S130, and the memristor array includes a plurality of memristor units arranged in an array. For example, the structural schematic diagram of the memristor array is shown in Figure 1 As shown, each memristor unit can be Figure 2A The 1T1R structure shown or Figure 2B The 2T2R structure shown.
[0075] like Figure 4 As shown, in step S110, the image to be processed and the structural element used for binary morphological operation are obtained.
[0076] For example, the image to be processed and the structural element are both binary images, both including a plurality of pixel points arranged in an array, and the value of each pixel point is one of a first value and a second value that are different from each other. For example, in the example described below, the first value is 0 and corresponds to white, and the second value is 1 and corresponds to black.
[0077] For example, the structure element includes an array origin, and the array origin can be any point in the structure element. For example, the array origin is the pixel point in the first row and first column in the upper left corner of the structure element, or the array origin can also be a reference pixel point in the structure element.
[0078] In step S120 , the value of each pixel in the image to be processed is mapped to a corresponding memristor unit in the memristor array.
[0079] For example, the values of each pixel of a binary image can be stored in a memristor array in the form of conductance, and the storage and computing advantages of the memristor array can be used to efficiently and quickly implement image morphological operations.
[0080] For example, the memristor unit has a first state and a second state. If the value of a pixel point in the image to be processed is a first value (for example, 0), the memristor unit at the position corresponding to the pixel point in the memristor array is set to the first state; if the value of the pixel point in the image to be processed is a second value (for example, 1), the memristor unit at the position corresponding to the pixel point in the memristor array is set to the second state.
[0081] For example, if the memristor unit is a 1T1R structure, the value of the pixel point can be represented as a first value or a second value by the high resistance state or low resistance state of the memristor of the memristor unit in the 1T1R structure. For example, by applying an on signal to the word line terminal WL, applying a read voltage to the bit line terminal BL, and applying a reference voltage (e.g., 0V) to the source line terminal SL, a current flowing through the memristor from the bit line terminal to the source line terminal can be obtained, and the resistance (i.e., the value) stored in the memristor can be obtained by the magnitude of the current. When the memristor is in a high resistance state, the current obtained is much smaller than the current when the memristor is in a low resistance state, and can even be ignored relative to the current when the memristor is in a low resistance state (i.e., it can be treated as 0).
[0082] If the memristor unit is a 2T2R structure, the value of the pixel point can be represented by the resistance difference between the two memristors R1 and R2 in the 2T2R structure. For example, a low resistance difference (such as 0) represents a first value, and a high resistance difference represents a second value.
[0083] For example, by applying an on signal to the word line terminal WL, applying a read voltage to the bit line terminal BL, and applying a reference voltage (e.g., 0V) to the source line terminal SL, a current flowing from the source line terminal to the bit line terminal and through the two memristors can be obtained. The resistance difference (i.e., numerical value) stored in the memristor can be obtained through the magnitude of the current. When the memristor is in a low resistance difference, the current obtained is much smaller than the current when the memristor is in a low resistance state, and can even be ignored relative to the current when the memristor is in a high resistance state (i.e., it can be treated as 0).
[0084] More specifically, if the memristor cell of the memristor array is a 1T1R structure, the first state of the memristor cell corresponds to the memristor in the memristor cell being in a high-resistance state, and the second state of the memristor cell corresponds to the memristor in the memristor cell being in a low-resistance state. For example, if the memristor cell of the memristor array is a 2T2R structure, such as Figure 2B As shown, the second state of the memristor unit corresponds to that the memristor R1 in the memristor unit has a low resistance state and the memristor R2 has a high resistance state, and the first state of the memristor unit corresponds to that the memristor R1 and the memristor R2 in the memristor unit have a high resistance state or a low resistance state at the same time. When the memristor R1 and the memristor R2 in the memristor unit have a low resistance state at the same time, the circuit energy consumption is higher than that when the memristor R1 and the memristor R2 in the memristor unit have a high resistance state at the same time.
[0085] In step S130, a structure element is used to sequentially traverse at least part of the pixels selected in the image to be processed, and in the process of traversing the image to be processed, for each selected pixel, each selected pixel is aligned with the array origin in the structure element, the structure element defines a window area in the image to be processed, the structure element and the window area are multiplied and processed through the memristor array, and a corresponding binary morphological result is obtained according to the calculation result of the multiplication and processing and the type of binary morphological operation.
[0086] For example, in step S130, as needed, the structural element may be used to sequentially traverse all or part of the pixels in the image to be processed, that is, at least part of the selected pixels may be all or part of the pixels in the processed image.
[0087] For example, a structure element includes m rows and n columns (m and n are both positive integers), and the structure element is used to traverse at least part of the pixels selected in the image to be processed in sequence. For each selected pixel in the at least part of the selected pixels, the selected pixel is aligned (overlapped) with the array origin in the structure element. The structure element defines a window area of m rows and n columns in the image to be processed, and the structure element and the window area are multiplied and processed through the memristor array to obtain a calculation result of the multiplication and processing; then, the corresponding binary morphological result is obtained according to the calculation result of the multiplication and processing and the type of binary morphological operation.
[0088] For example, for each of the m rows of the structural element, the n pixels in each row are multiplied one by one with the n pixels corresponding to each row in the window area according to the n positions in each row to obtain n products corresponding to each row. Thus, a total of m*n products are obtained for the m rows of the structural element, and the m*n products are summed to obtain the calculation result of the multiplication and sum processing.
[0089] More specifically, in the operation of the i-th row (i is a positive integer and less than or equal to m), the n pixel points in the i-th row of the structural element are multiplied one by one with the n pixel points corresponding to the n pixel points in the i-th row of the structural element in the window area of m rows and n columns defined by the structural element according to the n positions of the n pixel points in the i-th row, to obtain n products corresponding to the i-th row; after m operations are performed based on the value of i ranging from 1 to m, the above operations are performed on all m rows of the structural element, and a total of m*n products are obtained for the m rows of the structural element, and the m*n products are summed to obtain the calculation result of the multiplication and sum processing.
[0090] For example, when the corresponding binary morphological result is obtained according to the calculation result of the multiplication and processing and the type of binary morphological operation, for example, the type of binary morphological operation is a dilation operation and the calculation result of the multiplication and processing is greater than or equal to the second value, that is, the m*n products include at least one second value, then the corresponding binary morphological result is the second value, otherwise it is the first value; for example, when the type of binary morphological operation is an erosion operation and the calculation result of the multiplication and processing is equal to the number of pixel points in the structural element whose value is the second value, then the corresponding binary morphological result is the second value, otherwise it is the first value.
[0091] For example, the corresponding binary morphological result obtained through step S130 is the binary morphological result of the pixel point at the position corresponding to the reference pixel point of the structure element in the window area of m rows and n columns defined by the structure element.
[0092] Figure 5A A schematic diagram of an exemplary image to be processed and a structural element provided for at least one embodiment of the present disclosure. Figure 5A The left side is the image to be processed, and the right side is the structure element, where the row direction is from left to right and the column direction is from top to bottom. The structure element includes an array origin located in the first row and the first column. For example, starting from the pixel point of the first row and the first column of the image to be processed, the array origin of the structure element is aligned with the selected pixel point one by one to obtain the window area defined by the structure element in the image to be processed, for example, Figure 5A The dotted box in the middle is the window area defined by the structure element in the image to be processed when the array origin of the structure element is aligned with the selected pixel point at the position indicated by the arrow in the image to be processed.
[0093] Figure 5B FIG. 1 is a schematic diagram of a memristor array provided according to at least one embodiment of the present disclosure. Figure 5B As shown, the memristor array includes a plurality of memristor units MR arranged in an array, and includes M rows and N columns, that is, each row has N memristor units, and each column has M memristor units. For example, the structure of each memristor unit can be Figure 2A The 1T1R structure shown or Figure 2B 2T2R structure shown. Correspondingly, the memristor array also includes M word lines, M source lines and N bit lines, the M word lines and the M source lines correspond to M rows respectively, the N bit lines correspond to N columns respectively, and M and N are positive integers. In addition, as shown in the figure, the M source lines are connected to a current detection module (such as a current detection circuit), and the current detection module detects, accumulates and compares the signals on the corresponding source lines to obtain the corresponding binary morphological results.
[0094] For example, the structure element is m rows and n columns, based on Figure 5B The memristor array shown may include, when executing step S130: for each row of the structural element, applying an enable signal row by row to the word line of the selected row corresponding to each row in the window area, wherein the enable signal is used to turn on multiple memristor units corresponding to the selected row; based on the value of the pixel point of each row in the structural element, applying the input signal to the bit line of the memristor unit corresponding to the n pixel points of each row in the window area; obtaining the output current signal on the source line in the selected row, the output current signal corresponding to the n products corresponding to each row of the structural element; after obtaining the output current signals corresponding to the m rows, accumulating the m output current signals corresponding to the m rows of the structural element to obtain the total output current signal, the total output current signal corresponding to the calculation result of the multiplication and sum processing; obtaining the corresponding binary morphological result according to the calculation result of the multiplication and sum processing and the type of the binary morphological operation, for example, the corresponding binary morphological result obtained is the binary morphological result of the pixel point at the position corresponding to the reference pixel point of the structural element in the window area.
[0095] For example, in the first cycle, an enable signal is applied to the first row of the window area to turn on the multiple memristor units corresponding to the first row of the window area, so that the transistors of the multiple memristor units corresponding to the first row are in an on state, thereby performing a read operation on the multiple memristor units in the first row; then, in the second cycle, an enable signal is applied to the second row of the window area to turn on the multiple memristor units corresponding to the second row of the window area, so that the transistors of the multiple memristor units corresponding to the second row are in an on state, thereby performing a read operation on the multiple memristor units in the second row, and so on, until the enable signal is applied to the mth row of the window area in the mth cycle to perform subsequent operations.
[0096] For example, when performing a read operation, the input signal includes a first input signal corresponding to a first value and a second input signal corresponding to a second value, and the levels of the first input signal and the second input signal are different. For example, the first input signal represents a first input voltage (e.g., a ground voltage), and the second input signal represents a second input voltage, and the second input voltage is higher than the first input voltage. For example, in some examples, the first input voltage represents 0 volts and the second input voltage represents 0.15 volts.
[0097] For example, the input signal is a pulse signal, and the pulse amplitude of each pulse cycle is determined by the value of the pixel point at the corresponding position of the structural element. For example, the value of each column of the pixel point of the structural element is converted into the corresponding input signal according to the input direction, for example, the value of the first pixel point to the value of the mth pixel point of the i-th column of the structural element are respectively converted into the corresponding first input signal or second input signal, so as to obtain the pulse input signal corresponding to the i-th column, and the pulse input signals corresponding to the n-th columns of the structural element are applied to the bit lines of the memristor units corresponding to the n-th columns of the structural element in the window area, and cooperate with the word line signal of step S1301 to obtain the calculation result of the multiplication and processing.
[0098] For example, when each of the plurality of memristor units is turned on by receiving the start signal applied by the corresponding word line and the second input signal (e.g., the second input voltage, e.g., 0.15V) is applied to the corresponding bit line for reading, if the memristor unit is in the first state, that is, the value of the pixel corresponding to the memristor unit is the first value, then the memristor unit generates a first read current I1 on the corresponding source line; if the memristor unit is in the second state, that is, the value of the pixel corresponding to the memristor unit is the second value, then the memristor unit generates a second read current I2 on the corresponding source line. Usually, the second read current I2 is much larger than the first read current I1. For example, the first read current I1 may be equal to 0. For any row of memristor units, when the row of memristor units is read, the current generated on the corresponding source line is a*I1+b*I2, where a is the number of memristor units in the first state in the row, and b is the number of memristor units in the second state in the row. If I1 is equal to 0, the current generated on the corresponding source line is a*I1. When the corresponding binary morphological result is obtained according to the calculation result of the multiplication and sum processing and the type of binary morphological operation, if the total output current signal corresponding to the m rows of the structural element is greater than the reference current, the corresponding binary morphological result is the second value, otherwise it is the first value.
[0099] When the binary morphological operation is an image corrosion operation, according to the principle of image corrosion, the reference current is I1*(m*nV)+I2*V, where V is the number of pixel values in the structure element with m rows and n columns whose values are the second value. For the case where the first value is 0 (corresponding to white) and the second value is 1 (corresponding to black), the reference current represents the calculated value V. For example, for Figure 5A The structural element shown in the figure, the reference current at this time is 13*I1+3*I2, corresponding to the calculated value of 3; when the above-mentioned binary morphological operation is an image dilation operation, according to the principle of image dilation, the reference current is I1*(m*n-1)+I2, and for the case where the first value is 0 (corresponding to white) and the second value is 1 (corresponding to black), the reference current represents the calculated value of 1, for example, for Figure 5A For the structural element shown, the reference current at this time is 15*I1+I2, corresponding to a calculated value of 1.
[0100] Correspondingly, if the first read current I1 is equal to 0 (for example, including being actually 0 or being substantially 0 relative to the second read current), and the binary morphological operation is an image corrosion operation, according to the principle of image corrosion, the reference current can be set to I2*V, for example, Figure 5A For example, the binary morphological operation is an image dilation operation. According to the principle of image dilation, the reference current can be set to I2. Figure 5A For the structural element shown, the reference current at this time is I2.
[0101] For example, in some examples, when the number of first values in the structural element is large, the first read current I1 is small relative to I2 but not equal to 0, then the sum of the multiple first read currents I1 may exceed the second read current I2, thereby causing misjudgment of the expansion operation. Therefore, in order to improve the accuracy of the binary morphological result, when the binary morphological operation is an image expansion operation, the reference current can be simplified to I2+(V-1)*I1, thereby reducing the misjudgment rate of the expansion operation.
[0102] For example, in at least one example, Figure 5B The current detection module shown includes an integrator and a comparator. The output current corresponding to each row of the structural element is converted into a corresponding voltage signal after passing through the integrator and accumulated, thereby obtaining an output voltage signal corresponding to the total output current signal. The reference current is converted into a reference voltage obtained through the integrator, so that the corresponding binary morphological result can be obtained using the comparator according to the output voltage signal and the reference voltage. For example, the total output current signal is converted into a corresponding output voltage signal through an integrator. If the output voltage signal corresponding to the total output current signal is greater than the reference voltage, the corresponding binary morphological result is the second value, otherwise it is the first value.
[0103] For example, in at least one embodiment of the present disclosure, the structural element has a symmetrical structure symmetrical with respect to the central axis along the row direction, for example, the first row of m rows of structural elements is the same as the mth row, the second row is the same as the m-1th row, the third row is the same as the m-2th row, and so on. Fig. 6A The structural element shown in the figure has the same first row as the fifth row, and the same second row as the fourth row. At this time, due to the symmetrical structure of the structural element, the bit line signals applied to the two symmetrical rows are the same during operation, so the values of the same pixels in the two symmetrical rows can be converted into the bit line signals of the memristor units at the corresponding positions of the memristor array at the same time, and the two rows of pixels in the window area are processed in parallel, thereby increasing the processing efficiency and reducing the processing delay.
[0104] For example, when the structural element has a symmetrical structure with respect to the central axis along the row direction, based on Figure 5B The memristor array shown in the figure may include, when executing step S130: if the i-th row of the structural element has a symmetrical j-th row, applying a start signal to the word line of the first selected row corresponding to the i-th row in the window area and the word line of the second selected row corresponding to the j-th row in the window area at the same time; based on the value of the pixel point of the i-th row or the j-th row, applying the input signal to the bit lines of the memristor units in the window area corresponding to the positions of the n pixel points of the i-th row or the j-th row in the structural element; obtaining the first output current signal on the source line in the first selected row and the source line in the second selected row; The second output current signal on the line, for example, the first output current signal corresponds to the n products of the i-th row, and the second output current signal corresponds to the n products of the j-th row, that is, the output current signals corresponding to the two rows in the structural element are obtained simultaneously within one cycle; after obtaining the output current signals corresponding to the m rows respectively, the m output current signals corresponding to the m rows of the structural element are accumulated to obtain the total output current signal, and the total output current signal corresponds to the calculation result of the multiplication and processing; the corresponding binary morphological result is obtained according to the calculation result of the multiplication and processing and the type of binary morphological operation.
[0105] For example, after step S130, the judgment result of step S130 is stored, and for at least part of the selected pixels as all the pixels of the image to be processed, the method for implementing binary morphological operations based on a memristor array provided by the present disclosure may also include step S140: arranging the binary morphological results of all the pixels of the image to be processed according to the positions of all the pixels in the image to be processed to obtain the binary morphological results of the image to be processed. This step S140 uses the judgment result of step S130, and is executed based on the judgment result, for example, by software or hardware, and outputs the binary morphological results of the image to be processed, for example, in the form of a binary image (for example, reference Figure 3A and Figure 3B ).
[0106] For example, in some cases, the size of the initial image to be processed is large (for example, much larger than the size of the applicable memristor array). According to the image processing requirements and the processing delay requirements, the initial image can be divided into multiple images to be processed, and the multiple images to be processed are processed separately, for example, the multiple images to be processed are processed separately in a serial or parallel manner. For example, according to at least one embodiment of the present disclosure, obtaining the image to be processed may include dividing the initial image into regions to obtain multiple images to be processed, and the method for implementing binary morphological operations based on a memristor array also includes correspondingly splicing the binary morphological results of the multiple images to be processed according to the positional relationship of the multiple images to be processed in the initial image to obtain the binary morphological result of the initial image.
[0107] For instance, in some examples, the traversal of the structure element starts from the boundary of the image to be processed, for example, the array origin of the structure element located in the upper left corner is aligned with the pixel points of the first row and the first column of the image to be processed and the traversal starts. At this time, since the reference pixel point of the structure element may be located at any position of the structure element, for example, the reference pixel point of the structure element is located at the lower right corner of the structure element, the binary morphological result of the image to be processed obtained is composed of the binary morphological results of some pixel points in the image to be processed, and the edge pixel points of the image to be processed may not be processed at this time.
[0108] For example, in some other examples, the array origin of the structure element is also the reference pixel of the structure element, and the array origin is not located at the boundary of the structure element. Aligning the array origin with the pixels of the first row and the first column of the image to be processed will result in some pixels of the structure element not having corresponding positions in the image to be processed, that is, at this time, the window area defined for the structure element of m rows and n columns may be t rows and s columns, t is a positive integer and less than or equal to m, and s is a positive integer and less than or equal to n. In this case, when executing step S130, the part of the pixels in the structure element that do not have corresponding positions in the image to be processed can be ignored, and the p rows and q columns of pixels in the structure element and the window area that have a corresponding relationship are directly processed according to step S130. At this time, the binary morphological result of the image to be processed obtained is composed of the binary morphological results of all the pixels in the image to be processed, but the edge pixels of the binary morphological result of the image to be processed obtained by this method may produce processing errors.
[0109] Therefore, according to at least one embodiment of the present disclosure, obtaining an image to be processed may include: obtaining an initial image and performing edge pixel expansion on the initial image to obtain the image to be processed, where the initial image may be a complete image or a sub-image obtained by dividing an image of a larger size into regions. For example, the initial image is T rows and S columns, and the initial image includes four sides, namely, two sides in the row direction and two sides in the column direction, and the edge pixel expansion includes: extending at least one side in the row direction of the initial image by p pixels in a direction away from the initial image, wherein p is a positive integer and is less than or equal to m-1; extending at least one side in the column direction of the initial image by q pixels in a direction away from the initial image, wherein q is a positive integer and is less than or equal to n-1. For example, the values of p and q may be selected according to the image processing accuracy requirements. For example, if binary morphological processing is required for the edge pixels of the image, the upper side and the lower side of the initial image may be extended by m-1 pixels in a direction away from the initial image, and the left side and the right side of the initial image may be extended by n-1 pixels in a direction away from the initial image.
[0110] For example, in some examples, the initial image is a sub-image of the original image after region division, the upper side of the initial image is extended by 1 pixel in the direction away from the initial image, and the lower side of the initial image is extended by m-2 pixels in the direction away from the initial image. At this time, the area defined by the expanded upper side, the expanded lower side, the left side of the initial image, and the right side of the initial image in the original image is the image to be processed.
[0111] It should be noted that the portion of the image to be processed that corresponds to the initial image is the initial image portion, and the portion of the image to be processed other than the initial image portion is the extended portion, and the value of the pixel point of the extended portion can be the first value or obtained from the row portion or column portion corresponding to the adjacent sub-image of the initial image, or the value of the pixel point of the extended portion can be obtained by symmetrically flipping the pixel points of the initial image along the side of the initial image, and the present disclosure does not limit this. In addition, if the image to be processed is an image after the edge pixels are expanded, the window area does not exceed the range of the image to be processed.
[0112] The method provided in the above-mentioned some embodiments of the present disclosure is described below in a non-limiting manner using a specific example.
[0113] Fig. 6A This is a schematic diagram of a structural element of at least one embodiment of the present disclosure, wherein the structural element has 5 rows and 5 columns, and the pixel point in the upper left corner of the structural element is selected as the array origin, for example, the pixel point in the third row and third column of the structural element is the reference pixel point.
[0114] Figure 6B A schematic diagram of an original image provided by an embodiment of the present disclosure, wherein the original image is a complete image. For example, the original image is divided into regions to obtain multiple initial images, such as Figure 6B Each is shown in the thick black box.
[0115] Below Figure 6C Take this as an example to explain Fig. 6A The structural elements shown and Figure 6B The initial image shown in the present disclosure implements the Figure 5B The memristor array shown implements a preferred embodiment of the image binary morphological operation method.
[0116] like Figure 6C As shown, in the method of this embodiment, after obtaining the initial image and the structural element, the initial image is divided into image regions to obtain n regions, i.e., n partial initial images. Then, for each partial initial image, the edge pixel points are expanded to obtain the corresponding image to be processed, and the image to be processed is mapped to the memristor array; then, the image to be processed is traversed in sequence using the structural element to obtain the binary morphological result corresponding to each selected pixel point. Afterwards, the binary morphological result obtained based on each image to be processed is spliced based on the position correspondence of the corresponding partial initial image in the entire initial image, so that the binary morphological result of the initial image can be obtained.
[0117] First, if Figure 6C As shown, image region division is performed to obtain multiple partial initial images. The specific process is as described above and will not be repeated here.
[0118] Then, if Figure 6C As shown, edge pixel expansion is performed on each partial initial image to obtain an expanded image corresponding to each partial initial image.
[0119] For example, Fig.6D is a schematic diagram of an initial image involved in an embodiment of the present disclosure, for example, Fig.6D The initial image shown is Figure 6B The initial image shown in the figure is indicated by the arrow at the lower right corner. Fig.6D The initial image shown can also exist independently. Fig.6D The initial image shown includes 100 rows and 100 columns. Fig. 6E For Fig.6D The initial image shown is expanded by edge pixel points to obtain an image to be processed by the memristor array, and the image to be processed includes 104 rows and 104 columns, wherein the black thick line frame is the initial image portion in the image to be processed.
[0120] For example, in one example, in order to ensure that each pixel in the initial image can be processed, that is, the edge pixels of the initial image can also be processed by binary morphological operations, the reference pixel points are aligned with the pixel points at the four top corners of the initial image, and the number of extended rows or columns for each edge of the initial image is determined. For example, the reference pixel points are aligned with the pixel points in the first row and the first column of the initial image. Then, in order to obtain binary morphological results for the pixel points in the first row and the first column of the initial image, the upper side of the initial image can be expanded upward by two pixels, and the left side can be expanded to the left by two pixels; similarly, in order to obtain binary morphological results for the pixel points in the 100th row and the 100th column of the initial image, the lower side of the initial image can be expanded downward by two pixels, and the right side of the initial image can be expanded to the right by two pixels. At this time, the area defined by the four extended side edges is the image to be processed, such as Fig. 6E For example, the right side and the bottom side of the initial image overlap with the original image. In this case, the values of the pixels in the right and bottom extended parts of the image to be processed can be filled with the values of the pixels in the corresponding positions in the part of the initial image that is axially symmetrical with respect to the right side or the bottom side. For example, taking the right side as an example, the values of the pixels in the 101st and 102nd columns of the image to be processed are symmetrically filled to the 104th and 103rd columns respectively with the right side of the initial image as the axis.
[0121] Then, if Figure 6C As shown, the image to be processed is mapped to the memristor array. The specific method is as described in step S120 and will not be repeated here.
[0122] Then, if Figure 6C As shown, use Fig. 6A The structural elements shown are traversed in sequence Fig. 6E For the image to be processed shown in FIG. 1 , step S130 is executed. For example, in the process of traversing the image to be processed, for the i-th selected pixel point, the window area corresponding to the i-th selected pixel point is obtained, and for the j-th row of the five rows of the structural element, the turn-on signal is input into the word line corresponding to the j-th row of the window area row by row, and the values of the five pixel points of the j-th row of the structural element are converted into the corresponding input signals and input into the bit line of the memristor unit corresponding to the position of the five pixel points in the window area, and the output current signal on the source line corresponding to the j-th row of the window area is recorded at the same time; when the five rows of the structural element are all executed with the above operation, the sum of the output current signals corresponding to the five rows of the structural element is calculated, that is, the total output current, and the binary morphological result of the pixel point at the position corresponding to the reference pixel point in the structural element in the window area is determined according to the total output current.
[0123] The following takes the i-th selected pixel as Fig. 6E The execution process of step S130 is specifically described by taking the pixel points in the first row and the first column of the image to be processed as an example.
[0124] Fig. 6F A schematic diagram of the principle of image binary morphological processing provided by an embodiment of the present disclosure, such as Fig. 6F As shown, the array origin is aligned with the pixel points of the first row and the first column of the image to be processed, and the window area is defined by the structure element in the image to be processed, that is, Fig. 6F As shown in the dotted box in . In the first cycle, the first row of the structure element is multiplied one by one with the pixel points at the corresponding position of the first row of the window area, and 5 products corresponding to the first row of the structure element are obtained; in the second cycle, the second row of the structure element is multiplied one by one with the pixel points at the corresponding position of the second row of the window area, and 5 products corresponding to the second row of the structure element are obtained. And so on, after five cycles, 25 products are obtained, and the 25 products are summed to obtain the calculation result of the multiplication and sum processing. As shown in the figure, the calculation result of the multiplication and sum processing corresponding to the pixel points in the first row and the first column of the image to be processed is 7.
[0125] According to the principle of the aforementioned image dilation operation, if the multiplication and calculation result is greater than or equal to 1, the corresponding dilation result is 1, otherwise it is 0. At this time, the multiplication and processing calculation result is 7 and greater than 1, then the dilation result corresponding to the pixel point in the first row and the first column of the image to be processed is 1, that is, the pixel point in the window area corresponding to the reference pixel point of the structural element ( Fig. 6F The expansion result of the determined pixel in the structure element is 1. According to the principle of the above-mentioned image erosion operation, if the result of the multiplication and processing is greater than or equal to the number of pixels in the structure element whose value is 1 (here Fig. 6A The number of pixel values in the structure element shown is 13), then the corresponding erosion result is 1, otherwise it is 0. At this time, the multiplication and calculation result is 7 and less than 13, then the erosion result corresponding to the pixel point in the first row and the first column of the image to be processed is 0, that is, the pixel point in the window area corresponding to the reference pixel point of the structure element ( Fig. 6F The corrosion result of the judged pixel in is 0.
[0126] Figure 6G A schematic diagram of a binary morphological image processing process provided by another embodiment of the present disclosure is shown in FIG. Figure 6G As shown, since the structural element has a symmetrical structure with respect to the central axis along the row direction, that is, the first row and the fifth row of the structural element are the same, and the second row and the fourth row are also the same, since the input signal form of the bit line of the memristor unit at the corresponding position of each pixel point in the window area is determined by the value of the pixel point at the corresponding position of the structural element, for the first row and the fifth row, or the second row and the fourth row of the structural element, the bit line signal input to the window area is the same, and thus the first row and the fifth row, or the second row and the fourth row of the window area can be multiplied and processed at the same time, so that the multiplication and processing of the structural element and the window area can be completed in 3 cycles.
[0127] For example, in the first cycle, an on signal is applied to the word lines of the first row and the fifth row of the window area, so that the transistors of the multiple memristor units corresponding to the first row and the fifth row of the window area are in the on state; if only the value of the third pixel point in the first row and the fifth row of the structure element is 1, then only the third bit line among the five bit lines corresponding to the window area inputs a pulse signal (for example, the amplitude of the pulse signal is about 0.15 volts, and the width of the pulse signal is 50ns), and the other bit lines are kept in a low level state (for example, grounded), thereby realizing the multiplication and sum processing of the first row of the structure element and the first row of the window area, and the fifth row of the structure element and the fifth row of the window area, and obtaining the output current signal on the source line corresponding to the first row and the fifth row of the window area; and so on, in the second cycle, the output current signal on the source line corresponding to the second row and the fourth row of the window area is obtained, and in the third cycle, the output current signal on the source line corresponding to the third row of the window area is obtained.
[0128] After the three cycles are completed, the five current signals corresponding to the five rows of the structural element are accumulated to obtain the total output current signal, and the total output current signal is compared with the reference current signal to obtain the binary morphological result of the pixel being judged. Figure 5B The current detection module includes an integrator and a comparator. The output voltage signal after the accumulation of 5 output current signals is obtained through the integrator. If the output voltage signal is greater than the reference voltage converted by the integrator, the binary morphological result of the pixel being judged is 1, otherwise it is 0. For example, when the binary morphological operation is an expansion operation, only one memristor unit in the memristor array is in the second state, and the bit line of the memristor unit inputs a pulse signal (for example, the amplitude of the pulse signal is about 0.15 volts, and the width of the pulse signal is 50 ns), and other memristor units input low-level signals (for example, grounded), then the voltage value of the output current signal of the source line where the memristor unit is located after flowing through the integrator is the reference voltage; when the binary morphological operation is an corrosion operation, there are 14 memristor units in the memristor array in the second state, and the bit lines of these memristor units input pulse signals (for example, the amplitude of the pulse signal is about 0.15 volts, and the width of the pulse signal is 50 ns), and other memristor units input low-level signals (for example, grounded), and the voltage value of the sum of the output current signals of the source lines where these memristor units are located after flowing through the integrator is the reference voltage.
[0129] Finally, it is determined whether the processing of all pixels is completed, that is, whether the binary morphological results corresponding to all pixels of the initial image are obtained. If not, step S130 is continued to be executed for the next selected pixel. If completed, the scanning is stopped to obtain the binary morphological results corresponding to the image to be processed.
[0130] At least one embodiment of the present disclosure further provides an electronic device, Figure 7 A schematic block diagram of an electronic device provided for at least one embodiment of the present disclosure.
[0131] like Figure 7 As shown, the electronic device 800 includes at least one memristor array 801 and a controller 802. The memristor array 801 is configured to perform multiplication and calculation to obtain a binary morphological result, and the controller 802 is configured to perform steps S110 to S130. For example, the memristor array 801 and the controller 802 can communicate with each other through a system bus.
[0132] For example, the memristor array 801 may be configured as follows: Figure 5B As shown, the memristor array includes a plurality of memristor units MR arranged in an array, and includes M rows and N columns, that is, each row has N memristor units, each column has M memristor units, and the structure of each memristor unit can be Figure 2A The 1T1R structure shown or Figure 2B The memristor array further includes M word lines, M source lines and N bit lines, the M word lines and the M source lines correspond to M rows respectively, the N bit lines correspond to N columns respectively, and M and N are positive integers.
[0133] For example, the controller 802 may include a processing circuit and a memory, wherein the memory is used to store computer-readable instructions non-transitorily, and the memory may also store initial data required for processing and data generated by the processing (including intermediate data or final data). For example, the controller executes the program stored in the memory to implement the method of binary morphological operations in the same manner as the implementation method mentioned in the aforementioned method embodiment section for implementing binary morphological operations, and will not be repeated here.
[0134] For example, the electronic device 800 further includes a current detection module 803; for example, the current detection module 803 includes an accumulation unit and a comparison unit, the accumulation unit is configured to collect and accumulate the output current signal of the source line of the memristor array to obtain a total output current signal; the comparison unit is configured to compare the total output signal with the reference current. Figure 5B As shown, M source lines are connected to the current detection module 803, and the current detection module 803 detects, accumulates and compares the signals on the corresponding source lines to obtain corresponding binary morphological results.
[0135] For example, the accumulation unit can be an integrator, which is configured to convert the output current signal of the source line of the memristor array into a corresponding voltage signal and accumulate it to obtain an output voltage signal; the comparison unit is used to compare the magnitude relationship between the output voltage signal and the corresponding reference voltage signal obtained by the reference current passing through the integrator.
[0136] For example, Figure 7 As shown, the electronic device 800 may further include a source line driving circuit 805, a word line driving circuit 804, and a bit line driving circuit 806. For example, the word line driving circuit 804 is configured to apply control signals to the M word lines of the memristor array respectively. For example, the bit line driving circuit 806 is configured to apply input signals to the N bit lines of the memristor array. For example, the source line driving circuit 805 is configured to control the output signals of the M source lines of the memristor array, for example, the source line driving circuit 805 includes a control switch, and the control switch receives the control signal of the word line of the corresponding row to turn on or off, for example, the control signal of the word line of each row of the memristor array is simultaneously applied to the control switch in the source line driving circuit, at this time, if the control signal applied to the word line of the i-th row of the memristor array is an on signal, then the control switch corresponding to the i-th row in the source line driving circuit is turned on, and the output current on the source line of the i-th row can flow into the current detection module 803 to perform subsequent operations, i is a positive integer and is less than or equal to the number of rows of the structural element.
[0137] In addition, the electronic device 800 may also include an input interface and an output interface (not shown), and the memristor array 801, the controller 802, the input interface and the output interface may also communicate with each other through the system bus. For example, the input interface is configured to receive instructions from an external computer device, from a user, etc. to control the operation of the memristor array and the controller, etc. For example, an external device that communicates with the memristor array 801 and the controller 802 through the input interface and the output interface may be included in an environment that provides any type of user interface with which a user can interact. Examples of user interface types include graphical user interfaces, natural user interfaces, etc. For example, a graphical user interface may accept input from a user using input devices such as a keyboard, a mouse, a remote controller, etc., and provide output on an output device such as a display. In addition, a natural user interface may enable a user to interact with a parallel acceleration device in a manner that is not subject to constraints imposed by input devices such as a keyboard, a mouse, a remote controller, etc. In contrast, a natural user interface may rely on speech recognition, touch and stylus recognition, gesture recognition on and near the screen, air gestures, head and eye tracking, speech and voice, vision, touch, gestures, and machine intelligence, etc.
[0138] For example, the operation process of the electronic device 800 may refer to the relevant description in the above-mentioned method embodiment for implementing binary morphological operations based on a memristor array, and the repeated parts will not be repeated here.
[0139] There are a few points to note about this disclosure:
[0140] (1) The drawings of the embodiments of the present disclosure only relate to the structures related to the embodiments of the present disclosure, and other structures may refer to the general design.
[0141] (2) For the sake of clarity, the thickness and size of layers or structures are exaggerated in the drawings used to describe embodiments of the present invention. It is understood that when an element such as a layer, film, region, or substrate is referred to as being "on" or "under" another element, the element may be "directly" "on" or "under" the other element, or there may be intervening elements.
[0142] (3) In the absence of conflict, the embodiments of the present disclosure and the features therein may be combined with each other to obtain new embodiments.
[0143] The above description is only a specific implementation of the present disclosure, but the protection scope of the present disclosure is not limited thereto. The protection scope of the present disclosure shall be based on the protection scope of the claims.< / m> < / n> < / m>
Claims
1. A method for implementing binary morphological operations based on a memristor array, wherein: The memristor array includes a plurality of memristor units arranged in an array, and the method includes: Acquire an image to be processed and a structural element for the binary morphological operation, wherein the image to be processed and the structural element are both binary images, both include a plurality of pixel points arranged in an array, the value of each pixel point is one of a first value and a second value different from each other, and the structural element includes an array origin; Mapping the value of each pixel in the image to be processed to the memristor unit corresponding to the memristor array; Using the structural element to sequentially traverse at least part of the pixels selected in the image to be processed, and in the process of traversing the image to be processed, for each selected pixel, aligning the selected pixel with the array origin in the structural element, the structural element defines a window area in the image to be processed, performing multiplication and sum processing on the structural element and the window area through the memristor array, and obtaining a corresponding binary morphological result according to a calculation result of the multiplication and sum processing and a type of the binary morphological operation, wherein the memristor array is configured to perform multiplication and sum operations; Wherein, the structural element includes m rows and n columns, m and n are positive integers respectively, The step of multiplying and processing the structural element and the window area through the memristor array includes: For each of the m rows of the structure element, the n pixel points in each row are multiplied one by one with the n pixel points corresponding to each row in the window area according to the n positions in each row to obtain n products corresponding to each row, Thus, a total of m*n products are obtained for the m rows of the structure element, and the m*n products are summed to obtain the calculation result of the multiplication and summation process.
2. The method according to claim 1, wherein: The second value is used to identify a filled portion in the binary image, In response to the type of the binary morphological operation being a dilation operation and the calculation result of the multiplication and sum processing being greater than or equal to the second value, the corresponding binary morphological result is the second value, otherwise it is the first value; In response to the type of the binary morphological operation being an erosion operation and the calculation result of the multiplication and summing process being equal to the number of pixel points in the structural element whose pixel values are the second value, the corresponding binary morphological result is the second value, otherwise it is the first value.
3. The method according to claim 1, wherein: The memristor array includes M rows and N columns, and the memristor array also includes M word lines, M source lines and N bit lines, the M word lines and the M source lines correspond to the M rows respectively, the N bit lines correspond to the N columns respectively, and M and N are positive integers; For each row of the m rows of the structure element, the n pixel points in each row are multiplied one by one with the n pixel points corresponding to each row in the window area according to the n positions in each row to obtain n products corresponding to each row, including: Applying an enable signal row by row to a word line of a selected row corresponding to each row in the window region, wherein the enable signal is used to turn on a plurality of memristor units corresponding to the selected row; Based on the values of the pixels in each row in the structural element, input signals are applied to the bit lines of the memristor units corresponding to the positions of the n pixels in each row in the window area, respectively, wherein the input signals include a first input signal corresponding to the first value and a second input signal corresponding to the second value, and the first input signal and the second input signal are different; An output current signal on the source line in the selected row is obtained, wherein the output current signal corresponds to the n products corresponding to each row.
4. The method according to claim 1, wherein: The memristor array includes M rows and N columns, and the memristor array also includes M word lines, M source lines and N bit lines, the M word lines and the M source lines correspond to the M rows respectively, the N bit lines correspond to the N columns respectively, M and N are positive integers, and the structural element has a symmetrical structure symmetrical with respect to the central axis along the row direction, wherein, For each of the m rows of the structure element, the n pixel points in each row are multiplied one by one with the n pixel points in a row corresponding to the window area according to the n positions in each row, to obtain n products, including: In response to the i-th row of the structural element having a symmetrical j-th row, applying an on signal to a word line of a first selected row corresponding to the i-th row in the window region and a word line of a second selected row corresponding to the j-th row in the window region at the same time; Based on the values of the pixels in the i-th row or the j-th row, input signals are applied to the bit lines of the memristor units corresponding to the positions of the n pixels in the i-th row or the j-th row in the window area, respectively, wherein the input signals include a first input signal corresponding to the first value and a second input signal corresponding to the second value; A first output current signal on the source line in the first selected row and a second output current signal on the source line in the second selected row are obtained, wherein the first output current signal corresponds to n products of the i-th row, and the second output current signal corresponds to n products of the j-th row.
5. The method according to claim 3 or 4, wherein: Summing the m*n products to obtain a calculation result of the multiplication and summation process comprises: The m output current signals corresponding to the m rows of the structural element are accumulated to obtain a total output current signal, and the total output current signal corresponds to the calculation result of the multiplication and summation process.
6. The method according to claim 5, wherein: Each of the plurality of memristor cells has a first state and a second state, the first state being different from the second state, When each of the plurality of memristor units receives an on-signal applied by a corresponding word line and is turned on and the second input signal is applied to a corresponding bit line for reading, each of the plurality of memristor units generates a first read current I1 on a corresponding source line in response to the first state, and each of the plurality of memristor units generates a second read current I2 on a corresponding source line in response to the second state. The obtaining of the corresponding binary morphological result according to the calculation result of the multiplication and sum processing and the type of the binary morphological operation includes: In response to the total output current signal being greater than a reference current, the corresponding binary morphological result is the second value, otherwise it is the first value; or The total output current signal is converted into a corresponding output voltage signal. In response to the output voltage signal corresponding to the total output current signal being greater than a reference voltage, the corresponding binary morphological result is the second value, otherwise it is the first value.
7. The method according to claim 6, wherein: The first read current I1 is 0, In response to the binary morphological operation being an image corrosion operation, the reference current is I2*V, In response to the binary morphological operation being an image dilation operation, the reference current is I2, Wherein, V is the number of pixel points in the structural element whose value is the second value; and the reference voltage corresponds to the reference current.
8. The method according to claim 1, wherein: The at least some of the pixels selected in the image to be processed are all the pixels in the image to be processed, and the method further includes: The binary morphological results of all the pixels of the image to be processed are arranged according to the positions of all the pixels in the image to be processed to obtain the binary morphological results of the image to be processed.
9. The method according to claim 8, wherein: The obtaining of the image to be processed comprises: The initial image is divided into regions to obtain a plurality of images to be processed, and, The method further comprises: The binary morphological results of the plurality of images to be processed are correspondingly spliced according to the positional relationship of the plurality of images to be processed in the initial image to obtain the binary morphological result of the initial image.
10. The method according to claim 1, wherein: The obtaining of the image to be processed comprises: An initial image is acquired and edge pixel points of the initial image are expanded to obtain the image to be processed.
11. The method according to claim 10, wherein: The initial image has T rows and S columns, and includes two side edges in the row direction and two side edges in the column direction, and T and S are positive integers respectively. The step of performing edge pixel expansion on the acquired initial image includes: Extend at least one side of the initial image in the row direction by a total of p pixels in a direction away from the initial image, where p is a positive integer and is less than or equal to m-1; At least one side of the initial image in the column direction is extended by q pixels in a direction away from the initial image, where q is a positive integer and is less than or equal to n-1.
12. The method according to claim 1, wherein: Each of the plurality of memristor cells has a first state and a second state, The step of mapping the value of each pixel in the image to be processed to a memristor unit corresponding to the memristor array includes: In response to the value of each pixel in the to-be-processed image being the first value, setting the memristor unit at a position corresponding to each pixel in the memristor array to a first state; In response to the value of each pixel in the image to be processed being the second value, the memristor unit at a position corresponding to each pixel in the memristor array is set to a second state, The first state is different from the second state.
13. The method according to claim 1, wherein: The structural element also includes a reference pixel point, The corresponding binary morphological result is a binary morphological result of a pixel point at a position corresponding to the reference pixel point in the window area.
14. An electronic device comprising: A memristor array, wherein the memristor array is configured to perform multiplication and sum operations; A controller, wherein the controller is configured to perform the following steps: Acquire an image to be processed and a structural element for binary morphological operation, wherein the image to be processed and the structural element are both binary images, both include a plurality of pixel points arranged in an array, the value of each pixel point is one of a first value and a second value different from each other, and the structural element includes an array origin; Mapping the value of each pixel in the image to be processed to the memristor unit corresponding to the memristor array; Using the structural element to sequentially traverse at least part of the pixels selected in the image to be processed, and in the process of traversing the image to be processed, for each selected pixel, aligning each selected pixel with the array origin in the structural element, the structural element defines a window area in the image to be processed, performing multiplication and sum processing on the structural element and the window area through the memristor array, and obtaining a corresponding binary morphological result according to a calculation result of the multiplication and sum processing and a type of the binary morphological operation; Wherein, the structural element includes m rows and n columns, m and n are positive integers respectively, The step of multiplying and processing the structural element and the window area through the memristor array includes: For each of the m rows of the structure element, the n pixel points in each row are multiplied one by one with the n pixel points corresponding to each row in the window area according to the n positions in each row to obtain n products corresponding to each row, Thus, a total of m*n products are obtained for the m rows of the structure element, and the m*n products are summed to obtain the calculation result of the multiplication and summation process.
15. The electronic device according to claim 14, further comprising a current detection module, wherein: The current detection module includes an accumulation unit and a comparison unit; The accumulation unit is configured to collect and accumulate output current signals of source lines of the memristor array to obtain a total output current signal; The comparison unit is configured to compare the magnitude relationship between the total output current signal and a reference current.
16. The electronic device according to claim 14, further comprising a current detection module, wherein: The current detection module includes an accumulation unit and a comparison unit. The accumulation unit is an integrator, and the integrator is configured to convert the output current signal of the source line of the memristor array into a corresponding voltage signal and accumulate it to obtain an output voltage signal; The comparison unit is used to compare the magnitude relationship between the output voltage signal and a corresponding reference voltage signal obtained by the reference current passing through the integrator.
17. The electronic device according to claim 15 or 16, wherein: The memristor array includes a plurality of memristor units arranged in an array, the memristor array includes M rows and N columns, the M word lines and the M source lines correspond to the M rows respectively, and the N bit lines correspond to the N columns respectively; The memristor unit is a 1T1R or 2T2R structure.
18. The electronic device according to claim 17, further comprising: A source line driving circuit configured to control output signals of M source lines of the memristor array; a word line driving circuit configured to apply control signals to the M word lines of the memristor array respectively; The bit line driving circuit is configured to apply input signals to the N bit lines of the memristor array.
