CN113822980A - Method and device for removing image black edge, electronic equipment and storage medium - Google Patents

Method and device for removing image black edge, electronic equipment and storage medium Download PDF

Info

Publication number
CN113822980A
CN113822980A CN202110926174.0A CN202110926174A CN113822980A CN 113822980 A CN113822980 A CN 113822980A CN 202110926174 A CN202110926174 A CN 202110926174A CN 113822980 A CN113822980 A CN 113822980A
Authority
CN
China
Prior art keywords
image
transparent pixel
opaque
value
pixel point
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110926174.0A
Other languages
Chinese (zh)
Inventor
李天驰
孙悦
郑桂深
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Dianmao Technology Co Ltd
Original Assignee
Shenzhen Dianmao Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Dianmao Technology Co Ltd filed Critical Shenzhen Dianmao Technology Co Ltd
Priority to CN202110926174.0A priority Critical patent/CN113822980A/en
Publication of CN113822980A publication Critical patent/CN113822980A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/10Geometric effects
    • G06T15/20Perspective computation
    • G06T15/205Image-based rendering
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/77Retouching; Inpainting; Scratch removal

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Geometry (AREA)
  • Computer Graphics (AREA)
  • Image Generation (AREA)

Abstract

The invention discloses a method and a device for removing image black edges, electronic equipment and a storage medium, wherein the method comprises the following steps: obtaining transparent pixel points of an original image; according to the value of the alpha channel of the transparent pixel point, the transparent pixel point is modified into an opaque pixel point, and then an opaque image is generated; and rendering the opaque image to generate a target image. According to the embodiment of the invention, the transparent pixel points of the original image are changed into the opaque pixel points, so that the processed image has no transparent pixel points, and the image cannot be linearly filtered when the opaque image is rendered, therefore, the generated target image has no black edge, and the image quality of the target image is improved.

Description

Method and device for removing image black edge, electronic equipment and storage medium
Technical Field
The present invention relates to the field of image processing technologies, and in particular, to a method and an apparatus for removing an image black edge, an electronic device, and a storage medium.
Background
WebGL (Web Graphics Library) is a 3D drawing protocol, the drawing technical standard allows JavaScript and OpenGL ES 2.0 to be combined together, and by adding one JavaScript binding of OpenGL ES 2.0, WebGL can provide hardware 3D accelerated rendering for HTML5 Canvas, so that Web developers can more smoothly display 3D scenes and models in a browser by means of a system display card, and complicated navigation and data visualization can be created. Obviously, the WebGL technical standard eliminates the trouble of developing web page-specific rendering plug-ins, can be used to create web site pages with complex 3D structures, and can even be used to design 3D web games, and the like.
When a polygon in a three-dimensional space is changed into a group of pixel points on a two-dimensional screen through the processes of coordinate transformation, projection, rasterization and the like, each pixel point needs to be sampled in a corresponding texture image, and the process is called texture filtering.
The mixing in OpenGL is achieved by the following formula: result _ color SrcFactor + pixel _ color DstFactor
Wherein fragment _ color: a source color vector. This is the color vector originating from the texture. pixel _ color: a target color vector. This is the color vector currently stored in the color buffer. SrcFactor: a source factor value. The effect of the alpha value on the source color is specified. DstFactor: a target factor value. The impact of the value on the target color is specified.
Two texture filtering methods in the prior art are provided, the first method is to set a filtering mode of an image texture as Nearest neighbor interpolation sampling (Nearest Point Samplir) and obtain a target image according to a sampling result; the second method is to set the image mixed mode source factor value of the picture texture as float4(1.0,1.0,1.0,1.0), the target factor value is float4(1.0-fragment _ output.a), pre-multiply the picture, and obtain the target picture according to the pre-multiply result.
The first method can cause the picture to have saw teeth; the second scheme can affect the batch combination of the pictures by the game engine, and needs to be set in the engine, so that the steps are complicated, and the operation is inconvenient.
In the prior art, when a 3D image is subjected to linear filtering based on WebGL, after interpolation processing is performed on a picture color channel and background colors, the image has black edges, and the image quality is poor.
Accordingly, the prior art is yet to be improved and developed.
Disclosure of Invention
In view of the defects of the prior art, the invention provides a method, a device, electronic equipment and a storage medium for removing image black borders, and aims to solve the problem that when a 3D image is subjected to linear filtering based on WebGL in the prior art, the image has black borders and poor image quality after interpolation processing is performed on a picture color channel and a background color.
The technical scheme of the invention is as follows:
the first embodiment of the invention provides a method for removing black edges of an image, which comprises the following steps:
obtaining transparent pixel points of an original image;
according to the value of the alpha channel of the transparent pixel point, the transparent pixel point is modified into an opaque pixel point, and then an opaque image is generated;
and rendering the opaque image to generate a target image.
Further, obtaining the transparent pixel point of the original image includes:
traversing the value of an alpha channel of a pixel point in the original image;
if the alpha channel value of the pixel point is 0, judging the pixel point to be a transparent pixel point;
and obtaining transparent pixel points of the original image.
Further, after modifying the transparent pixel point into an opaque pixel point according to the value of the alpha channel of the transparent pixel point, generating an opaque image comprises:
obtaining the value of an alpha channel of a transparent pixel point of an original image, and recording the value as a first alpha channel value;
acquiring the value of an alpha channel of a non-transparent pixel point closest to a transparent pixel point adjacent to the original image, and recording the value as a second alpha channel value;
obtaining an average value of the first alpha channel value and the second alpha channel value, and recording the average value as a third alpha channel value;
after the value of the alpha channel of the transparent pixel point is set to be a third alpha channel value, an opaque pixel point is generated;
and obtaining non-transparent pixel points in the original image, and combining the non-transparent pixel points with the non-transparent pixel points to obtain the non-transparent image.
Further, traversing the values of the alpha channels of the pixels in the original image comprises:
traversing the value of an alpha channel of a pixel point in the original image in a pointer access mode;
or traversing the value of an alpha channel of a pixel point in the original image in an iterator iteration mode;
or traversing the alpha channel value of the pixel point in the original image by a dynamic address operation mode.
Further, according to the alpha channel of the transparent pixel point, after the transparent pixel point is modified into the opaque pixel point, generating the opaque image comprises:
obtaining non-transparent pixel points in an original image;
modifying the alpha channel value of the transparent pixel point to a designated value to generate an opaque pixel point;
and combining the opaque pixel points and the non-transparent pixel points to obtain an opaque image.
Further, rendering the opaque image, and after generating the target image, the method further includes:
and exporting the target image into a picture format, storing the target image to a specified position, and deleting the original image.
Further, rendering the opaque image, and after generating the target image, the method further includes:
and exporting the target image into a picture format and storing the target image to a specified position.
Another embodiment of the present invention provides an apparatus for removing a black edge of an image, the apparatus including:
the transparent pixel point acquisition module is used for acquiring transparent pixel points of the original image;
the opaque image generation module is used for generating an opaque image after modifying the transparent pixel points into opaque pixel points according to the values of the alpha channels of the transparent pixel points;
and the image generation module is used for rendering the opaque image to generate a target image.
Another embodiment of the present invention provides an electronic device comprising at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to cause the at least one processor to perform the method for removing black borders of an image.
Another embodiment of the present invention also provides a non-transitory computer-readable storage medium storing computer-executable instructions that, when executed by one or more processors, cause the one or more processors to perform the method for removing black borders of an image described above.
Has the advantages that: according to the embodiment of the invention, the transparent pixel points of the original image are changed into the opaque pixel points, so that the processed image has no transparent pixel points, and the image cannot be linearly filtered when the opaque image is rendered, therefore, the generated target image has no black edge, and the image quality of the target image is improved.
Drawings
The invention will be further described with reference to the accompanying drawings and examples, in which:
FIG. 1 is a flowchart illustrating a method for removing black edges of an image according to a preferred embodiment of the present invention;
FIG. 2 is a schematic diagram illustrating an image and a background superimposed according to an embodiment of the present invention;
FIG. 3 is a flowchart illustrating an embodiment of a method for removing a black edge of an image according to the present invention;
FIG. 4 is a functional block diagram of an apparatus for removing black edges of an image according to an embodiment of the present invention;
fig. 5 is a schematic diagram of a hardware structure of an electronic device according to a preferred embodiment of the invention.
Detailed Description
In order to make the objects, technical solutions and effects of the present invention clearer and clearer, the present invention is described in further detail below. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Embodiments of the present invention will be described below with reference to the accompanying drawings.
Referring to fig. 1, fig. 1 is a flowchart illustrating a method for removing a black edge of an image according to a preferred embodiment of the present invention. As shown in fig. 1, it includes the steps of:
s100, obtaining transparent pixel points of an original image;
specifically, the method for removing the image black edge in the embodiment of the present invention is applied to electronic devices, the electronic devices include but are not limited to smart devices such as a mobile phone, a tablet, a personal computer, and a notebook computer, and the method for removing the image black edge is mainly used for web applications, for example, can be used for web games. In a Web game, a plurality of pictures need to be rendered, and the Web game is also called a Web game and is called a Web game for endless online games. The online multi-person interactive game based on the Web browser does not need to download a client, does not have the problem of insufficient machine configuration, and is most importantly extremely convenient to close or switch. Further, the method for removing the image black border of the embodiment of the invention can be used for 3D webpage games. When the image in the three-dimensional space is changed into a group of pixel points on a two-dimensional screen by processes of coordinate transformation, projection, rasterization and the like, each pixel point needs to be sampled. And the original image to be processed refers to an image of the three-dimensional space that is not filtered.
Because the transparent pixel points are contained, the black edge phenomenon can occur when the transparent pixel points are combined with the background layer in the image rendering process. Therefore, the transparent pixel points of the image need to be processed. Firstly, all transparent pixel points of an original image are obtained. The regions in the transparent pixel point layer are completely transparent, and the regions are formed by transparent pixel points. When the attributes of the transparent pixel points in the layer are locked, the region containing the transparent pixel points in the layer is not affected by editing or drawing operation. Through the transparent pixel points in the layer, the content of the layer below the layer can be read.
In some other embodiments, some other methods may also be used to obtain the transparent pixel points of the image, which is not limited to this.
S200, according to the value of an alpha channel of a transparent pixel point, modifying the transparent pixel point into an opaque pixel point, and then generating an opaque image;
in specific implementation, all transparent pixel points of an original image are obtained, the transparent pixel points are modified into opaque pixel points, and a modified opaque image is generated and recorded as an opaque image. An opaque pixel point means that the pixel point is not transparent. The alpha channel value of the transparent pixel is 0, and the non-transparent pixel is a pixel with the alpha channel value not being 0. And modifying the value of the alpha channel to realize that the opaque image is generated after the transparent pixel point is modified into the opaque pixel point. Transparent pixel points do not exist in the opaque image.
In some other embodiments, setting the peripheral pixels in the picture to opaque may also be used.
Step S300, rendering the opaque image to generate a target image;
in specific implementation, the opaque image is rendered through a mixed mode, the specific rendering method is rendered by using OpenGL (Open Graphics Library, or Open Graphics Library), and the specific rendering formula is reset _ color SrcFactor + pixel _ color DstFactor; fragment _ color: a source color vector, which is a color vector originating from the texture. pixel _ color: a target color vector, which is the color vector currently stored in the color buffer. SrcFactor: a source factor value specifying the effect of the alpha value on the source color. DstFactor: a target factor value specifying an effect of the value on the target color.
OpenGL is a cross-language, cross-platform Application Programming Interface (API) for rendering 2D, 3D vector graphics. This interface consists of nearly 350 different function calls to draw from simple graphics bits to complex three-dimensional scenes. Yet another program interface system is Direct3D used only on Microsoft Windows. OpenGL is commonly used in CAD, virtual reality, scientific visualization programs, and electronic game development.
Efficient implementations of OpenGL (using graphics acceleration hardware) exist in Windows, parts of UNIX platform and Mac OS.
In one embodiment, acquiring the raw image to be processed comprises:
and acquiring an original image to be processed, and loading the original image to a memory.
In specific implementation, after an original image to be processed is obtained, the original image is loaded to a memory of the electronic device. This may be accomplished in a language such as c #, python, or the like, which has authority to operate system files.
A Memory (Memory) is one of important parts of a computer, and is also called an internal Memory and a main Memory for temporarily storing operation data in a CPU and data exchanged with an external Memory such as a hard disk. The computer is a bridge for communicating an external memory with a CPU, all programs in the computer are operated in the internal memory, and the level of the overall performance of the computer is influenced by the strength of the internal memory. As long as the computer starts to run, the operating system transfers the data to be operated to the CPU from the memory for operation, and when the operation is finished, the CPU transmits the result.
In some other embodiments, the original image may be loaded into a storage device such as an image cache. After the image is processed, the processed image is deleted from the buffer. Cache refers to a storage capable of high-speed data exchange, and the data exchange with the CPU is performed before the memory, so that the speed is high. L1 Cache (level one Cache) is the CPU level one Cache. The capacity and structure of the built-in L1 cache have a great influence on the performance of the CPU, but the cache memory is composed of static RAM, the structure is complex, and the capacity of the L1 level cache cannot be made too large under the condition that the die area of the CPU cannot be too large. The typical L1 cache size is typically 32-256 KB. The L2 Cache (level two Cache) is the second level Cache of the CPU, divided into internal and external chips. The operation speed of the internal chip secondary cache is the same as the main frequency, and the external secondary cache is only half of the main frequency. The L2 cache capacity also affects CPU performance, the principle being that the larger the better, the L2 cache for ordinary desktop CPUs is typically 128KB to 2MB or higher, and the L2 cache for CPUs used on notebooks, servers, and workstations can be up to 1MB-3 MB. Since the higher the speed of the cache memory, the more expensive the cache memory, there are computer systems in which two or more levels of cache memory are provided. The first level cache memory, which is in close proximity to the memory, is highest in speed and smallest in size, and the second level cache memory is slightly larger in size and slightly lower in speed.
In one embodiment, obtaining transparent pixel points of an original image comprises:
traversing the value of an alpha channel of a pixel point in the original image;
if the alpha channel value of the pixel point is 0, judging the pixel point to be a transparent pixel point;
and obtaining transparent pixel points of the original image.
In specific implementation, the transparency of the image is represented by an alpha channel in the embodiment of the invention, the values of the alpha channels of the pixels are detected when all the pixels in the original image are traversed, if the values of the alpha channels of the pixels are detected to be 0, the pixels are determined to be transparent pixels, and the pixels of which the values of all the alpha channels in the original image are 0 are obtained.
Alpha Channel or Alpha Channel refers to the transparency and translucency of a picture. For example: a bitmap stored using 16 bits per pixel may have 5 bits for red, 5 bits for green, 5 bits for blue, and the last bit for alpha for each pixel in the graph. In this case it either means transparent or not, because the alpha bit has only the possibility of two different representations, 0 or 1. As another example, a bitmap stored using 32 bits, each 8 bits representing a red, green, blue, and alpha channel. In this case, neither light can represent transparent or opaque, and the alpha channel can also represent 256 levels of translucency, since there are 8 bits of the alpha channel that can have 256 different data representation possibilities. By obtaining the value of the alpha channel, whether the current pixel is a transparent pixel can be rapidly obtained according to the value of the alpha channel.
In one embodiment, traversing the values of the alpha channel for pixel points in the original image comprises:
traversing the value of an alpha channel of a pixel point in the original image in a pointer access mode;
or traversing the value of an alpha channel of a pixel point in the original image in an iterator iteration mode;
or traversing the alpha channel value of the pixel point in the original image by a dynamic address operation mode.
In specific implementation, the operation of traversing pixel points is supported by almost all languages, for example, the C + + pixel point traversing method has multiple types: pointer access, iterator, and dynamic address operation.
Pointer access to data typically has two methods, one by means of operators and one by means of operators- >, where operators are mostly used for pointers of struct structure types and pointers of non-struct types are mostly used for accessing data.
Iterators (iterators), sometimes also called cursors, are software design models of programming, interfaces that can be accessed over container objects (containers, such as linked lists or arrays), and designers need not be concerned with the implementation details of memory allocation for container objects.
The modes of implementing iterators in various languages are different, some object-oriented languages such as Java, C #, Ruby, Python and Delphi have built-in characteristics of iterators in languages, and are perfectly integrated with the languages, so that the iterators are called as implicit iterators (implictors), but the C + + language does not have the characteristics of the iterators, but the STL still utilizes templates to implement powerful iterators. The memory address of the data of the STL container may be reallocated and the iterator bound to the container may still locate the correct memory address after reallocation.
Iterators can on the other hand also integrate generators (generators). Some languages treat both as the same interface, and some languages, such as JavaScript, make them independent.
Furthermore, the element traversal is realized by using the dynamic address calculation in cooperation with the at access pixel points.
The pixel point traversal can be realized through various traversal modes, and the corresponding traversal mode can be selected according to the requirement in practical application.
In one embodiment, after modifying the transparent pixel points into the opaque pixel points according to the alpha channel of the transparent pixel points, generating the opaque image includes:
obtaining non-transparent pixel points in an original image;
modifying the alpha channel value of the transparent pixel point to a designated value to generate an opaque pixel point;
and combining the opaque pixel points and the non-transparent pixel points to obtain an opaque image.
In specific implementation, an alpha channel of a pixel point is checked, if the value is equal to 0, the pixel point is judged to be a transparent pixel point, the alpha channel value is directly modified to be a designated value, an opaque pixel point is generated, a non-transparent pixel point in an original image is obtained, the non-transparent pixel point and the opaque pixel point are combined to generate an opaque image, and the opaque image does not contain the pixel point with the transparency of 0. The designated value is smaller than 255, for example, the designated value may be set to 1, and when the value of the alpha channel of the pixel point is determined to be 0, the value of the alpha channel is modified to 1. By modifying the value of the alpha channel, the transparent pixel point can be rapidly modified into the opaque pixel point, and convenience is provided for the subsequent image rendering.
In one embodiment, after modifying the transparent pixel point into an opaque pixel point according to the value of the alpha channel of the transparent pixel point, generating the opaque image includes:
obtaining the value of an alpha channel of a transparent pixel point of an original image, and recording the value as a first alpha channel value;
acquiring the value of an alpha channel of a non-transparent pixel point closest to a transparent pixel point adjacent to the original image, and recording the value as a second alpha channel value;
obtaining an average value of the first alpha channel value and the second alpha channel value, and recording the average value as a third alpha channel value;
after the value of the alpha channel of the transparent pixel point is set to be a third alpha channel value, an opaque pixel point is generated;
and obtaining non-transparent pixel points in the original image, and combining the non-transparent pixel points with the non-transparent pixel points to obtain the non-transparent image.
In specific implementation, the value of the alpha channel of the transparent pixel of the original image is obtained, if the value is equal to 0, the transparent pixel is determined to be the transparent pixel and recorded as a first alpha channel value, and the value of the alpha channel of the non-transparent pixel closest to the transparent pixel adjacent to the original image is obtained and recorded as a second alpha channel value. Generally, the non-transparent pixel point closest to the transparent pixel point in the straight line distance is used as a target non-transparent pixel point, and if a plurality of non-transparent pixel points closest to the straight line distance exist, one non-transparent pixel point is selected as the target non-transparent pixel point.
And averaging the first alpha channel value and the second alpha channel value to generate a third alpha channel value, and taking the third alpha channel value as a new alpha channel value of the transparent pixel point to generate the opaque pixel point.
Obtaining non-transparent pixel points in an original image, combining the non-transparent pixel points and opaque pixel points to generate an opaque image, wherein the opaque image does not contain pixel points with the transparency of 0. When the transparent pixel point is modified, the alpha channel value of the non-transparent pixel point adjacent to the transparent pixel point is referred, the modified non-transparent pixel point and the original non-transparent pixel point have certain gradual change, and the image quality is improved.
In one embodiment, rendering the opaque image, and generating the target image further includes:
and exporting the target image into a picture format, storing the target image to a specified position, and deleting the original image.
In specific implementation, after the pixel points are determined to be traversed completely (namely, the second step of traversal is completed), the modified information is exported to be in a picture format, and is stored in a designated position of a hard disk, and the original file is selected to be covered. The original file is covered, so that the new picture and the old picture are prevented from occupying a large amount of storage space, and the storage space of the system is saved.
In one embodiment, rendering the opaque image, and generating the target image further includes:
and exporting the target image into a picture format and storing the target image to a specified position.
In specific implementation, after the pixel points are determined to be traversed, the modified information is exported to be in a picture format and stored in a designated position of a hard disk, so that the original file is not covered, and the modified information can be additionally stored as other files. In some scenarios, in order to prevent the target icon from not meeting the pixel requirement, the original picture and the target picture may also be saved simultaneously.
In one embodiment, as shown in fig. 2, the working principle of the embodiment of the present invention is to add the transparency pixel points and the low transparency pixel points on the picture layer, so that the transparent pixel points around the picture layer are changed into the low transparency pixel points. Because the processed picture does not have pixel points with the transparency of 0, the webGL can not carry out linear filtering during rendering, the sawtooth condition can not occur, and the scheme does not change the default mixed mode of the picture, so the batch operation of a game engine can not be influenced.
The embodiment of the present invention further provides a flowchart of a specific application embodiment of a method for eliminating an image black edge, as shown in fig. 3, where the method includes:
importing the picture into a memory; the process of loading pictures into the memory can be easily realized through languages of authorized operating system files such as c #, python, and the like.
From left to right, from top to bottom, image pixel points are traversed one by one, and the operation of traversing the pixel points is supported by almost all languages, for example, the C + + pixel point traversing method has multiple types: 1. pointer access; 2. an iterator; 3. a dynamic address at;
judging whether a pixel point with the transparency of 0 exists or not; if yes, setting the transparency of the pixel point to be 1; if not, not processing; checking an alpha channel of the pixel point, if the value is equal to 0, judging the pixel point to be a transparent pixel point, and directly modifying the value of the alpha channel to 1 in the next step;
and judging whether the traversal of the pixel points is finished or not, if not, continuously traversing the pixel points, and if the pixel points are determined to be completely traversed (namely, the traversal of the second step is finished), exporting the modified information into a picture format, storing the picture format in a designated position of a hard disk, and selectively covering the original file or additionally playing the file.
It should be noted that, a certain order does not necessarily exist between the above steps, and those skilled in the art can understand, according to the description of the embodiments of the present invention, that in different embodiments, the above steps may have different execution orders, that is, may be executed in parallel, may also be executed interchangeably, and the like.
Another embodiment of the present invention provides an apparatus for removing a black edge of an image, as shown in fig. 4, the apparatus 1 includes:
a transparent pixel point obtaining module 11, configured to obtain a transparent pixel point of an original image;
the opaque image generation module 12 is configured to modify the transparent pixel points into opaque pixel points according to the values of the alpha channels of the transparent pixel points, and then generate an opaque image;
and an image generating module 13, configured to render the opaque image and generate a target image.
The specific implementation is shown in the method embodiment, and is not described herein again.
Another embodiment of the present invention provides an electronic device, as shown in fig. 5, an electronic device 10 includes:
one or more processors 110 and a memory 120, where one processor 110 is illustrated in fig. 5, the processor 110 and the memory 120 may be connected by a bus or other means, and where fig. 5 illustrates a connection by a bus.
The processor 110 is used to implement various control logic for the electronic device 10, which may be a general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA), a single chip, an ARM (Acorn RISC machine) or other programmable logic device, discrete gate or transistor logic, discrete hardware controls, or any combination of these components. Also, the processor 110 may be any conventional processor, microprocessor, or state machine. Processor 110 may also be implemented as a combination of computing devices, e.g., a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a DSP core, or any other such configuration.
The memory 120, which is a non-volatile computer-readable storage medium, may be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as program instructions corresponding to the method for removing the image black border in the embodiment of the present invention. The processor 110 executes various functional applications and data processing of the device 10, namely, implements the method of removing image black borders in the above-described method embodiments, by running the nonvolatile software programs, instructions and units stored in the memory 120.
The memory 120 may include a storage program area and a storage data area, wherein the storage program area may store an application program required for operating the device, at least one function; the storage data area may store data created according to the use of the device 10, and the like. Further, the memory 120 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some embodiments, memory 120 optionally includes memory located remotely from processor 110, which may be connected to device 10 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
One or more units are stored in the memory 120, and when executed by the one or more processors 110, perform the method of removing image black borders in any of the above-described method embodiments, e.g., performing the above-described method steps S100 to S300 in fig. 1.
Embodiments of the present invention provide a non-transitory computer-readable storage medium storing computer-executable instructions for execution by one or more processors, for example, to perform method steps S100-S300 of fig. 1 described above.
By way of example, non-volatile storage media can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), electrically erasable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM), which acts as external cache memory. By way of illustration and not limitation, RAM is available in many forms such as Synchronous RAM (SRAM), dynamic RAM, (DRAM), Synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), Enhanced SDRAM (ESDRAM), Synchlink DRAM (SLDRAM), and Direct Rambus RAM (DRRAM). The disclosed memory controls or memories of the operating environments described herein are intended to comprise one or more of these and/or any other suitable types of memory.
Another embodiment of the present invention provides a computer program product comprising a computer program stored on a non-volatile computer-readable storage medium, the computer program comprising program instructions which, when executed by a processor, cause the processor to perform the method of removing image black borders of the above method embodiment. For example, the method steps S100 to S300 in fig. 1 described above are performed.
The above-described embodiments are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of the embodiment.
Through the above description of the embodiments, those skilled in the art will clearly understand that the embodiments may be implemented by software plus a general hardware platform, and may also be implemented by hardware. Based on such understanding, the above technical solutions essentially or contributing to the related art can be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as ROM/RAM, magnetic disk, optical disk, etc., and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of the various embodiments or some parts of the embodiments.
Conditional language such as "can," "might," or "may" is generally intended to convey that a particular embodiment can include (yet other embodiments do not include) particular features, elements, and/or operations, among others, unless specifically stated otherwise or otherwise understood within the context as used. Thus, such conditional language is also generally intended to imply that features, elements, and/or operations are in any way required for one or more embodiments or that one or more embodiments must include logic for deciding, with or without input or prompting, whether such features, elements, and/or operations are included or are to be performed in any particular embodiment.
What has been described herein in the specification and drawings includes examples that can provide a method and apparatus for removing image black borders. It will, of course, not be possible to describe every conceivable combination of components and/or methodologies for purposes of describing the various features of the disclosure, but it can be appreciated that many further combinations and permutations of the disclosed features are possible. It is therefore evident that various modifications can be made to the disclosure without departing from the scope or spirit thereof. In addition, or in the alternative, other embodiments of the disclosure may be apparent from consideration of the specification and drawings and from practice of the disclosure as presented herein. It is intended that the examples set forth in this specification and the drawings be considered in all respects as illustrative and not restrictive. Although specific terms are employed herein, they are used in a generic and descriptive sense only and not for purposes of limitation.

Claims (10)

1. A method for removing black edges from an image, the method comprising:
obtaining transparent pixel points of an original image;
according to the value of an alpha channel of a transparent pixel point, modifying the transparent pixel point into an opaque pixel point, and then generating an opaque image;
and rendering the opaque image to generate a target image.
2. The method of claim 1, wherein obtaining transparent pixel points of an original image comprises:
traversing the value of an alpha channel of a pixel point in the original image;
if the alpha channel value of the pixel point is 0, judging the pixel point to be a transparent pixel point;
and obtaining transparent pixel points of the original image.
3. The method according to claim 1 or 2, wherein the generating an opaque image after modifying the transparent pixel points into opaque pixel points according to the values of the alpha channels of the transparent pixel points comprises:
obtaining the value of an alpha channel of a transparent pixel point of an original image, and recording the value as a first alpha channel value;
acquiring the value of an alpha channel of a non-transparent pixel point closest to a transparent pixel point adjacent to the original image, and recording the value as a second alpha channel value;
obtaining an average value of the first alpha channel value and the second alpha channel value, and recording the average value as a third alpha channel value;
after the value of the alpha channel of the transparent pixel point is set to be a third alpha channel value, an opaque pixel point is generated;
and obtaining non-transparent pixel points in the original image, and combining the non-transparent pixel points and the non-transparent pixel points to obtain the non-transparent image.
4. The method of claim 2, wherein traversing the values of the alpha channel for the pixel points in the original image comprises:
traversing the value of an alpha channel of a pixel point in the original image in a pointer access mode;
or traversing the alpha channel value of the pixel point in the original image in an iterator iteration mode;
or traversing the alpha channel value of the pixel point in the original image by a dynamic address operation mode.
5. The method according to claim 1 or 2, wherein the generating an opaque image after modifying the transparent pixel points into opaque pixel points according to the values of the alpha channels of the transparent pixel points comprises:
obtaining non-transparent pixel points in an original image;
modifying the alpha channel value of the transparent pixel point to a designated value to generate an opaque pixel point;
and combining the opaque pixel points and the non-transparent pixel points to obtain an opaque image.
6. The method of claim 1, wherein rendering the opaque image to generate the target image further comprises:
and exporting the target image into a picture format, storing the target image to a specified position, and deleting the original image.
7. The method of claim 1, wherein rendering the opaque image to generate the target image further comprises:
and exporting the target image into a picture format and storing the target image to a specified position.
8. An apparatus for removing black edges from an image, the apparatus comprising:
the transparent pixel point acquisition module is used for acquiring transparent pixel points of the original image;
the opaque image generation module is used for generating an opaque image after modifying the transparent pixel points into opaque pixel points according to the values of the alpha channels of the transparent pixel points;
and the image generation module is used for rendering the opaque image to generate a target image.
9. An electronic device, characterized in that the electronic device comprises at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of removing image black borders of any of claims 1-7.
10. A non-transitory computer-readable storage medium storing computer-executable instructions that, when executed by one or more processors, cause the one or more processors to perform the method of removing image black borders of any of claims 1-7.
CN202110926174.0A 2021-08-12 2021-08-12 Method and device for removing image black edge, electronic equipment and storage medium Pending CN113822980A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110926174.0A CN113822980A (en) 2021-08-12 2021-08-12 Method and device for removing image black edge, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110926174.0A CN113822980A (en) 2021-08-12 2021-08-12 Method and device for removing image black edge, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113822980A true CN113822980A (en) 2021-12-21

Family

ID=78922759

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110926174.0A Pending CN113822980A (en) 2021-08-12 2021-08-12 Method and device for removing image black edge, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113822980A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024096662A1 (en) * 2022-11-04 2024-05-10 삼성전자 주식회사 Electronic device, operation method, and storage medium for analyzing and improving image quality of transparent background image

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024096662A1 (en) * 2022-11-04 2024-05-10 삼성전자 주식회사 Electronic device, operation method, and storage medium for analyzing and improving image quality of transparent background image

Similar Documents

Publication Publication Date Title
KR100962920B1 (en) Visual and scene graph interfaces
JP5242789B2 (en) Mapping of graphics instructions to related graphics data in performance analysis
US8237728B2 (en) Methods, systems, and data structures for generating a rasterizer
US9916674B2 (en) Baking path rendering objects into compact and efficient memory representations
CN108765534A (en) A kind of image rendering method, device, equipment and storage medium
KR20150091132A (en) Page rendering method and apparatus
TW201737207A (en) Method and system of graphics processing enhancement by tracking object and/or primitive identifiers, graphics processing unit and non-transitory computer readable medium
NO328434B1 (en) Formatting language and object model for vector graphics
AU2014202321A1 (en) Print-ready document editing using intermediate format
CN115330986B (en) Method and system for processing graphics in block rendering mode
CN109634611B (en) Mobile terminal three-dimensional model ply file analysis and display method based on OpenGL
CN113822980A (en) Method and device for removing image black edge, electronic equipment and storage medium
CN112348938A (en) Method, device and computer equipment for optimizing three-dimensional object
AU2010241218B2 (en) Method, apparatus and system for associating an intermediate fill with a plurality of objects
JP5242788B2 (en) Partition-based performance analysis for graphics imaging
US7535480B2 (en) Compositing rendering layers
US20240127525A1 (en) Method and system for processing graphics in tile-based rendering mode
US20240127524A1 (en) Method and system for processing graphics in tile-based rendering mode
US11217005B1 (en) Techniques for rendering 2D vector graphics on mobile devices
KR101966247B1 (en) Processing device of 3d image and operating method thereof
CN117953121A (en) Graphic rendering method and device and electronic equipment
Nilsson Optimization Methods for Direct Volume Rendering on the Client Side Web
Hoddie et al. Drawing Graphics with Poco
CN113487725A (en) Model node modification method and device, terminal device and storage medium
CN115294261A (en) Image coloring processing method and related equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination