CN113034372A - Rapid rotation method of underwater image - Google Patents

Rapid rotation method of underwater image Download PDF

Info

Publication number
CN113034372A
CN113034372A CN202110283862.XA CN202110283862A CN113034372A CN 113034372 A CN113034372 A CN 113034372A CN 202110283862 A CN202110283862 A CN 202110283862A CN 113034372 A CN113034372 A CN 113034372A
Authority
CN
China
Prior art keywords
image
angle
original image
new
leftbottom
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.)
Granted
Application number
CN202110283862.XA
Other languages
Chinese (zh)
Other versions
CN113034372B (en
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.)
Oceanographic Instrumentation Research Institute Shandong Academy of Sciences
Original Assignee
Oceanographic Instrumentation Research Institute Shandong Academy of Sciences
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 Oceanographic Instrumentation Research Institute Shandong Academy of Sciences filed Critical Oceanographic Instrumentation Research Institute Shandong Academy of Sciences
Priority to CN202110283862.XA priority Critical patent/CN113034372B/en
Publication of CN113034372A publication Critical patent/CN113034372A/en
Application granted granted Critical
Publication of CN113034372B publication Critical patent/CN113034372B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/60Rotation of whole images or parts thereof
    • G06T3/608Rotation of whole images or parts thereof by skew deformation, e.g. two-pass or three-pass rotation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/70Determining position or orientation of objects or cameras
    • G06T7/73Determining position or orientation of objects or cameras using feature-based methods

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Image Processing (AREA)

Abstract

The invention discloses a method for rapidly rotating an underwater image, which comprises the following steps: setting the coordinate of one vertex of the original image as a coordinate origin, establishing a coordinate system, and calculating the coordinates of four vertexes of the original image after rotation according to the direction and the angle to be rotated; calculating the number of rows and columns of a new image according to the calculated coordinates of the four vertexes, wherein the new image is a square frame which just covers all pixel points of the original image; traversing all points corresponding to the rows and the columns of the original image, and calculating the row and column indexes of each point in a new image; and assigning the pixel values of all traversed points in the original image to the corresponding row index and column index of each point in the new image to obtain the new image containing the pixel values of all the pixel points of the original image, and setting the rest pixel points in the new image to be white. The method disclosed by the invention can improve the efficiency and accuracy of image analysis.

Description

Rapid rotation method of underwater image
Technical Field
The invention belongs to the technical field of image analysis, and particularly relates to a rapid rotation method of an underwater image.
Background
In the process of analyzing the underwater sea image, the underwater image is shot to deviate and rotate due to the fluctuation of the sea water, so that the image acquired by the image is an inclined image, and the analysis result of the underwater sea image is influenced. The method for rotating the underwater images of the seawater is necessary for analyzing the underwater images of the ocean and is the core of the current domestic underwater image analysis of the ocean.
In the actual operation process, the measurement of the underwater image of the sea is interfered by the change of the marine environment, the phenomenon is that the image rotates irregularly, and even on the basis of collecting the underwater image of the sea, the underwater image is not the true position of the underwater image. In the underwater image detection process, rotation calculation is performed on an image. For the above reasons, the existing rotation method for detecting the underwater image of the seawater has no real-time property. Therefore, in order to obtain a detection result of a real underwater image of seawater, a rapid rotation method of the underwater image must be found in field measurement, and the position of each pixel point in the image must be determined.
Disclosure of Invention
In order to solve the technical problem, the invention provides a method for rapidly rotating an underwater image so as to achieve the purpose of improving the efficiency and accuracy of image analysis.
In order to achieve the purpose, the technical scheme of the invention is as follows:
a method for rapidly rotating an underwater image comprises the following steps:
(1) setting the coordinate of one vertex of the original image as a coordinate origin, establishing a coordinate system, and calculating the coordinates of four vertexes of the original image after rotation according to the direction and the angle to be rotated;
(2) calculating the number of rows and columns of a new image according to the calculated coordinates of the four vertexes, wherein the new image is a square frame which just covers all pixel points of the original image;
(3) traversing all points corresponding to the rows and the columns of the original image, and calculating the row and column indexes of each point in a new image;
(4) and assigning the pixel values of all traversed points in the original image to the corresponding row index and column index of each point in the new image to obtain the new image containing the pixel values of all the pixel points of the original image, and setting the rest pixel points in the new image to be white.
In the scheme, the specific method of the step (1) is as follows:
the original image is a square image, the upper left vertex of the original image is set as the origin of coordinates, the original image is rotated around the origin of coordinates, Y is the number of lines of the original image, X is the number of columns of the original image, and Angle is the Angle of rotation, then the X and Y coordinates of the four vertices of the rotated original image are calculated as follows:
lower left vertex:
LeftBottom(x)=(Y-1)*sin(Angle);
LeftBottom(y)=(Y-1)*cos(Angle);
top left vertex:
LeftTop(x)=0;
LeftTop(y)=0;
lower right vertex:
RightBottom(x)=(X-1)*cos(Angle)+(Y-1)*sin(Angle);
RightBottom(y)=-(X-1)*sin(Angle)+(Y-1)*cos(Angle);
top right vertex:
RightTop(x)=(X-1)*cos(Angle);
RightTop(y)=-(X-1)*sin(Angle)。
in the scheme, the specific method of the step (2) is as follows: the row number of the new image is the maximum row number of the four vertexes minus the minimum row number of the four vertexes, and the column number of the new image is the maximum column number of the four vertexes minus the minimum column number of the four vertexes, and the specific formula is as follows:
Xnew=max([LeftTop(x),LeftBottom(x),RightTop(x),RightBottom(x)])-min([LeftTop(x),LeftBottom(x),RightTop(x),RightBottom(x)]);
Ynew=max([LeftTop(y),LeftBottom(y),RightTop(y),RightBottom(y)])-min([LeftTop(y),LeftBottom(y),RightTop(y),RightBottom(y)]);
wherein, XnewFor new image column number, YnewThe number of rows for the new image.
In the above scheme, the specific method of step (3) is as follows:
Yn=1+round(-indexX*sin(Angle)+indexY*cos(Angle))+round(abs(min([LeftTop(y),LeftBottom(y),RightTop(y),RightBottom(y)])));
Xn=round(indexX*cos(Angle)+indexY*sin(Angle))+round(abs(min([LeftTop(x),LeftBottom(x),RightTop(x),RightBottom(x)])))+1;
wherein, YnFor any point's row index in the new image, XnFor any point in the new image, index is the column index, Y is the number of lines in the original image, X is the number of columns in the original image, Y is the column index of the original imageoFor any point in the line index of the original image, XoFor any point in the row index of the original image, Angle is the rotation Angle, abs is the absolute value, min is the minimum value, and round is the integer.
Through the technical scheme, the rapid rotation method of the underwater image provided by the invention is not limited by accumulation time and marine environment interference, can rapidly identify the true position of the pixel point in the seawater underwater image, and achieves the purpose of improving the efficiency and accuracy of underwater image analysis.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below.
FIG. 1 is a schematic flow chart of a fast rotation method for underwater images according to an embodiment of the present invention;
FIG. 2 illustrates an image rotation process according to an embodiment of the present invention.
Detailed Description
The technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
The embodiment of the invention provides a method for rapidly rotating an underwater image, which comprises the following steps as shown in figure 1:
(1) setting the coordinate of one vertex of the original image as a coordinate origin, establishing a coordinate system, and calculating the coordinates of four vertexes of the original image after rotation according to the direction and the angle to be rotated;
in the present embodiment, as shown in fig. 2, the acquired underwater image is a single-channel grayscale image with a width of 640 pixels and a height of 480 pixels; the upper left corner of the original image is O (0, 0); the lower left corner is a (479, 0); c (0, 639) at the upper right corner, B (479, 639) at the lower right corner, 480 pixels in row number Y, and 640 pixels in column number X; if required by 30. Angle is 30; sin (30) ═ 0.5; cos (30) ═ 0.866; after rotation, the x, y coordinates of the four vertices are calculated as follows:
lower left vertex a':
LeftBottom(x)=(Y-1)*sin(Angle)=479*0.5=239.5;
LeftBottom(y)=(Y-1)*cos(Angle)=479*0.866=414.814;
upper left vertex O:
LeffTop(x)=0;
LeftTop(y)=0;
lower right vertex B':
RightBottom(x)=(X-1)*cos(Angle)+(Y-1)*sin(Angle)
=639*0.866+479*0.5=792.874;
RightBottom(y)=-(X-1)*sin(Angle)+(Y-1)*cos(Angle)
=-639*0.5+479*0.866=95.314;
upper right vertex C':
RightTop(x)=(X-1)*cos(Angle)=639*0.866=553.374;
RightTop(y)=-(X-1)*sin(Angle)=-639*0.5=-319.5。
(2) calculating the number of rows and columns of a new image according to the calculated coordinates of the four vertexes, wherein the new image is a square frame (a dotted frame surrounded by DEGF in fig. 2) which just covers all pixel points of the original image; the specific method comprises the following steps:
line number Y of new imagenewColumn number X of new image by subtracting the minimum number of rows of four vertices from the maximum number of rows of four verticesnewThe number of columns with the four vertices being the largest minus the number of columns with the four vertices being the smallest is given by the following formula:
Xnew=max([LeftTop(x),LeftBottom(x),RightTop(x),RightBottom(x)])-min([LeftTop(x),LeftBottom(x),RightTop(x),RightBottom(x)])
=max(239.5,0,792.874,553.374)-min(239.5,0,792.874,553.374)
=792.874-0
=792.874
=793;
Ynew=max([LeftTop(y),LeftBottom(y),RightTop(y),RightBottom(y)])-min([LeftTop(y),LeftBottom(y),RightTop(y),RightBottom(y)])
=max(414.814,0,95.314,-319.5)-min(414.814,0,95.314,-319.5)
=414.814-(-319.5)
=734.314
=734;
therefore, a new image after rotation is obtained as an image of 734 rows and 793 columns.
(3) Traversing all points corresponding to the rows and the columns of the original image, and calculating the row and column indexes of each point in a new image;
in this embodiment, the original image is 640 x 480, so that after 640 columns are traversed, each column traverses 480 rows again, i.e., from the (0, 0) point to the (639, 479) point.
For example: a point (3, 5) with rows and columns of 3 and 5 respectively in the original image, indexX being 5 and indexY being 3; its gray value is 3, calculate the row index and column index of the point in the new image:
Yn=1+round(-indexX*sin(Angle)+indexY*cos(Angle))+round(abs(min([LeftTop(y),LeftBottom(y),RightTop(y),RightBottom(y)])))
=1+round(5*0.5+3*0.866)+round(abs(min(414.814,0,95.314,-319.5)))
=1+roung(2.5+2.598)+round(319.5)
=1+5+320;
=326;
Xn=round(indexX*cos(Angle)+indexY*sin(Angle))+round(abs(min([LeftTop(x),LeftBottom(x),RightTop(x),RightBottom(x)])))+1
=round(5*0.866+3*0.5)+round(abs(min(239.5,0,792.874,553.374)))+1
=round(5.83)+0+1;
=7;
wherein, YnFor the line index of the point in the new image, XnThe column index of the point in the new image, index, Y the number of lines of the original image, X the number of columns of the original image, YoFor the line index of the point in the original image, XoThe column index of the point in the original image, Angle is the rotation Angle, abs is the absolute value, min is the minimum value, and round is the rounding.
Thus, point (3, 5) corresponds to the rotated position of 326 rows, 7 columns, i.e., point (326, 7).
(4) And assigning the pixel values of all traversed points in the original image to the row and column indexes of each point in the new image to obtain the new image containing the pixel values of all the pixel points of the original image, and setting the rest pixel points in the new image to be white.
In this embodiment, the rotated new image is an image in 734 rows and 793 columns, the original image covers the pixels corresponding to the new image, and the remaining pixels are all initial values, white, and the pixel value is 255.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (4)

1. A method for rapidly rotating an underwater image is characterized by comprising the following steps:
(1) setting the coordinate of one vertex of the original image as a coordinate origin, establishing a coordinate system, and calculating the coordinates of four vertexes of the original image after rotation according to the direction and the angle to be rotated;
(2) calculating the number of rows and columns of a new image according to the calculated coordinates of the four vertexes, wherein the new image is a square frame which just covers all pixel points of the original image;
(3) traversing all points corresponding to the rows and the columns of the original image, and calculating the row and column indexes of each point in a new image;
(4) and assigning the pixel values of all traversed points in the original image to the corresponding row index and column index of each point in the new image to obtain the new image containing the pixel values of all the pixel points of the original image, and setting the rest pixel points in the new image to be white.
2. The fast rotation method of underwater images according to claim 1, characterized in that the specific method of step (1) is as follows:
the original image is a square image, the upper left vertex of the original image is set as the origin of coordinates, the original image is rotated around the origin of coordinates, Y is the number of lines of the original image, X is the number of columns of the original image, and Angle is the Angle of rotation, then the X and Y coordinates of the four vertices of the rotated original image are calculated as follows:
lower left vertex:
LeftBottom(x)=(Y-1)*sin(Angle);
LeftBottom(y)=(Y-1)*cos(Angle);
top left vertex:
LeftTop(x)=0;
LeftTop(y)=0;
lower right vertex:
RightBottom(x)=(X-1)*cos(Angle)+(Y-1)*sin(Angle);
RightBottom(y)=-(X-1)*sin(Angle)+(Y-1)*cos(Angle);
top right vertex:
RightTop(x)=(X-1)*cos(Angle);
RightTop(y)=-(X-1)*sin(Angle)。
3. the fast rotation method of underwater images as claimed in claim 1, characterized in that the specific method of step (2) is as follows: the row number of the new image is the maximum row number of the four vertexes minus the minimum row number of the four vertexes, and the column number of the new image is the maximum column number of the four vertexes minus the minimum column number of the four vertexes, and the specific formula is as follows:
Xnew=max([LeftTop(x),LeftBottom(x),RightTop(x),RightBottom(x)])-min([LeftTop(x),LeftBottom(x),RightTop(x),RightBottom(x)]);
Ynew=max([LeftTop(y),LeftBottom(y),RightTop(y),RightBottom(y)])-min([LeftTop(y),LeftBottom(y),RightTop(y),RightBottom(y)]);
wherein, XnewFor new image column number, YnewThe number of rows for the new image.
4. The fast rotation method of underwater images as claimed in claim 1, characterized in that the specific method of step (3) is as follows:
Yn=1+round(-indexX*sin(Angle)+indexY*cos(Angle))+round(abs(min([LeftTop(y),LeftBottom(y),RightTop(y),RightBottom(y)])));
Xn=round(indexX*cos(Angle)+indexY*sin(Angle))+round(abs(min([LeftTop(x),LeftBottom(x),RightTop(x),RightBottom(x)])))+1;
wherein, YnFor any point's row index in the new image, XnFor any point in the new image, index is the column index, Y is the number of lines in the original image, X is the number of columns in the original image, Y is the column index of the original imageoFor any point in the line index of the original image, XoFor any point in the row index of the original image, Angle is the rotation Angle, abs is the absolute value, min is the minimum value, and round is the integer.
CN202110283862.XA 2021-03-17 2021-03-17 Rapid rotation method of underwater image Active CN113034372B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110283862.XA CN113034372B (en) 2021-03-17 2021-03-17 Rapid rotation method of underwater image

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110283862.XA CN113034372B (en) 2021-03-17 2021-03-17 Rapid rotation method of underwater image

Publications (2)

Publication Number Publication Date
CN113034372A true CN113034372A (en) 2021-06-25
CN113034372B CN113034372B (en) 2022-12-20

Family

ID=76470844

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110283862.XA Active CN113034372B (en) 2021-03-17 2021-03-17 Rapid rotation method of underwater image

Country Status (1)

Country Link
CN (1) CN113034372B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112364190A (en) * 2020-11-16 2021-02-12 北京工业大学 Spherical image indexing method and device

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112364190A (en) * 2020-11-16 2021-02-12 北京工业大学 Spherical image indexing method and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
杜冬: "自动几何校正中摄像机的自动校正方法", 《中国民航飞行学院学报》 *
王小芳等: "基于图像转置算法的研究", 《电脑知识与技术》 *

Also Published As

Publication number Publication date
CN113034372B (en) 2022-12-20

Similar Documents

Publication Publication Date Title
CN111260731B (en) Self-adaptive detection method for checkerboard sub-pixel level corner points
CN108369650B (en) Method for identifying possible characteristic points of calibration pattern
CN107203973B (en) Sub-pixel positioning method for center line laser of three-dimensional laser scanning system
CN107545207A (en) DM two-dimensional code identification methods and device based on image procossing
CN112767359B (en) Method and system for detecting corner points of steel plate under complex background
CN107192716A (en) A kind of workpiece, defect quick determination method based on contour feature
CN104715491B (en) A kind of sub-pixel edge detection method based on one-dimensional Gray Moment
CN111462066A (en) Thread parameter detection method based on machine vision
CN104715487A (en) Method for sub-pixel edge detection based on pseudo Zernike moments
CN111524139B (en) Bilateral filter-based corner detection method and system
CN116883887A (en) Leakage gas detection method for infrared video
CN116862910A (en) Visual detection method based on automatic cutting production
CN116503462A (en) Method and system for quickly extracting circle center of circular spot
CN115018785A (en) Hoisting steel wire rope tension detection method based on visual vibration frequency identification
CN112801141B (en) Heterogeneous image matching method based on template matching and twin neural network optimization
CN113034372B (en) Rapid rotation method of underwater image
CN116612461A (en) Target detection-based pointer instrument whole-process automatic reading method
CN114863258B (en) Method for detecting small target based on visual angle conversion in sea-sky-line scene
CN111178111A (en) Two-dimensional code detection method, electronic device, storage medium and system
CN113034364B (en) Reverse generation method for underwater image rotation
CN111553874B (en) Light center extraction method for surface line structure of light-reflecting nuclear fuel rod
CN112819823A (en) Furniture board-oriented circular hole detection method, system and device
CN117876468B (en) Convex hull-based detection method and system for low-beam light type characteristic points of automobile lamplight
CN117152622B (en) Boundary optimization model training, boundary optimization method, device, equipment and medium
CN114240946B (en) Locator abnormality detection method, system, storage medium and computing device

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
GR01 Patent grant
GR01 Patent grant