Skip to content

Commit 5300e2b

Browse files
update
1 parent c0316cb commit 5300e2b

File tree

7 files changed

+44
-25
lines changed

7 files changed

+44
-25
lines changed

src_code/README-Chinese.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ![image](https://user-images.githubusercontent.com/113756063/194830221-abe24fcc-484b-4769-b3b7-ec6d8138f436.png) 算法之星-机器大脑
22

3-
- Switch to [English Document](https://github.com/BeardedManZhao/algorithmStar/blob/main/src_code/update/1.14_1.15.md)
3+
- Switch to [English Document](https://github.com/BeardedManZhao/algorithmStar/blob/main/src_code/README.md)
44
- knowledge base
55
<a href="https://github.com/BeardedManZhao/algorithmStar/blob/main/KnowledgeDocument/knowledge%20base-Chinese.md">
66
<img src = "https://user-images.githubusercontent.com/113756063/194838003-7ad14dac-b38c-4b57-a942-ba58f00baaf7.png"/>
@@ -669,7 +669,7 @@ public class MAIN1 {
669669
// 将一些图像文件转换成为一个图像矩阵对象
670670
ColorMatrix colorMatrix1 = ColorMatrix.parseGrayscale("C:\\Users\\Liming\\Desktop\\fsdownload\\test2.bmp");
671671
// 对图像进行二值化
672-
colorMatrix1.globalBinary(ColorMatrix._G_, 100 , 0xffffff, 0);
672+
colorMatrix1.globalBinary(ColorMatrix._G_, 100, 0xffffff, 0);
673673
colorMatrix1.show("腐蚀之前的 image");
674674
// 开始对图像矩阵进行腐蚀操作
675675
colorMatrix1.erode(2, 2, false).show("腐蚀之后的 image");

src_code/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ![image](https://user-images.githubusercontent.com/113756063/194830221-abe24fcc-484b-4769-b3b7-ec6d8138f436.png) Algorithm Star-MachineBrain
22

3-
- 切换到 [中文文档](https://github.com/BeardedManZhao/algorithmStar/blob/main/src_code/update/1.14_1.15-Chinese.md)
3+
- 切换到 [中文文档](https://github.com/BeardedManZhao/algorithmStar/blob/main/src_code/README-Chinese.md)
44
- knowledge base
55
<a href="https://github.com/BeardedManZhao/algorithmStar/blob/main/KnowledgeDocument/knowledge%20base.md">
66
<img src = "https://user-images.githubusercontent.com/113756063/194832492-f8c184c1-55e8-4f16-943a-34b99ac751d4.png"/>
Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
package zhao.algorithmMagic;
22

3-
import zhao.algorithmMagic.operands.matrix.ColorMatrix;
3+
import zhao.algorithmMagic.operands.table.FDataFrame;
4+
import zhao.algorithmMagic.operands.table.FinalSeries;
45

56
import java.sql.SQLException;
67

7-
88
public class MAIN1 {
99
public static void main(String[] args) throws SQLException {
10-
// 将一些图像文件转换成为一个图像矩阵对象
11-
ColorMatrix colorMatrix1 = ColorMatrix.parseGrayscale("C:\\Users\\Liming\\Desktop\\fsdownload\\test2.bmp");
12-
// 对图像进行二值化
13-
colorMatrix1.globalBinary(ColorMatrix._G_, 100 , 0xffffff, 0);
14-
colorMatrix1.show("腐蚀之前的 image");
15-
// 开始对图像矩阵进行腐蚀操作
16-
colorMatrix1.erode(2, 2, false).show("腐蚀之后的 image");
10+
// 创建一个空的 DataFrame 对象
11+
FDataFrame select = FDataFrame.select(
12+
FinalSeries.parse("id", "name", "sex", "age"), 1
13+
);
14+
// 手动插入数据
15+
select.insert(
16+
FinalSeries.parse("1", "zhao", "M", "19"),
17+
FinalSeries.parse("1", "tang", "W", "18"),
18+
FinalSeries.parse("1", "yang", "W", "20")
19+
);
20+
21+
System.out.println(select);
1722
}
1823
}

src_code/src/main/java/zhao/algorithmMagic/operands/matrix/ColorMatrix.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,11 +1171,25 @@ public double avg(byte colorMode) {
11711171
* @return 图像矩阵经过了腐蚀操作之后返回的新矩阵对象。
11721172
*/
11731173
public ColorMatrix erode(int width, int height, boolean isCopy) {
1174+
return erode(width, height, isCopy, Color.BLACK);
1175+
}
1176+
1177+
/**
1178+
* 图像腐蚀函数,在该函数的处理之下,可以对图像某些不足够的颜色数值进行腐蚀操作,
1179+
*
1180+
* @param width 用于腐蚀的图像卷积核的宽度
1181+
* @param height 用于腐蚀的图像卷积核的高度
1182+
* @param isCopy 如果设置为true 则代表在一个新的矩阵对象中进行腐蚀的操作计算,如果设置为false 则代表在原矩阵的基础上进行腐蚀不会出现新矩阵对象。
1183+
* @param backColor 图像矩阵中的背景颜色数据对像,在该对象中有很多的颜色,您需要指定一种颜色作为图像矩阵中的腐蚀者身份。
1184+
* @return 图像矩阵经过了腐蚀操作之后返回的新矩阵对象。
1185+
*/
1186+
public ColorMatrix erode(int width, int height, boolean isCopy, Color backColor) {
11741187
// 计算出来最终的图像的长宽
11751188
int rowCount = this.getRowCount() - (this.getRowCount() % height);
11761189
int colCount = this.getColCount() - (this.getColCount() % width);
11771190
int maxRowIndex = rowCount - height - 1;
11781191
int maxColIndex = colCount - width - 1;
1192+
int colorNum = backColor.getRGB();
11791193
ColorMatrix res = isCopy ? ColorMatrix.parse(this.copyToNewArrays()) : this;
11801194
// 开始不断的提取出子矩阵数据
11811195
for (int y = 0; y < maxRowIndex; ) {
@@ -1188,20 +1202,20 @@ public ColorMatrix erode(int width, int height, boolean isCopy) {
11881202
boolean isR = false;
11891203
for (Color[] colors : nowSub.toArrays()) {
11901204
for (Color color : colors) {
1191-
if (color.getRGB() == 0xff000000) {
1205+
if (color.getRGB() == colorNum) {
11921206
// 发现了黑色 直接将该子矩阵中的所有颜色更换为黑色
11931207
isR = true;
11941208
}
11951209
}
11961210
if (isR) {
11971211
for (Color[] toArray : nowSub.toArrays()) {
1198-
Arrays.fill(toArray, Color.BLACK);
1212+
Arrays.fill(toArray, backColor);
11991213
}
12001214
break;
12011215
}
12021216
}
12031217
// 一行的检测结束,如果这一行中有黑色像素,那么代表子矩阵被替换完毕,进行合并
1204-
if (isR){
1218+
if (isR) {
12051219
// 合并子矩阵到矩阵中
12061220
res.merge(nowSub, x, y);
12071221
}

src_code/src/main/java/zhao/algorithmMagic/operands/vector/SparkVector.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,6 @@ final class SparkVector(sparkContext: SparkContext, vector: org.apache.spark.mll
5353
else throw new OperatorOperationException("'DoubleVector1 multiply DoubleVector2' 时,两个'DoubleVector'的向量所包含的数量不同,DoubleVector1=[" + length1 + "],DoubleVector2=[" + length2 + "]\n" + "When 'DoubleVector1 multiply DoubleVector2', the two vectors of 'DoubleVector' contain different quantities, DoubleVector1=[" + length1 + "], DoubleVector2=[" + length2 + "]")
5454
}
5555

56-
/**
57-
*
58-
* @return 将本对象中存储的向量序列数组拷贝到一个新数组并将新数组返回,这里返回的是一个新数组,支持修改等操作。
59-
*
60-
* Copy the vector sequence array stored in this object to a new array and return the new array. Here, a new array is returned, which supports modification and other operations.
61-
*/
62-
override def copyToNewArray(): Array[Double] = vector.toArray
63-
6456
/**
6557
* 计算两个向量的内积,也称之为数量积,具体实现请参阅api说明
6658
* <p>
@@ -85,6 +77,14 @@ final class SparkVector(sparkContext: SparkContext, vector: org.apache.spark.mll
8577
else throw new OperatorOperationException("'DoubleVector1 innerProduct DoubleVector2' 时,两个'DoubleVector'的向量所包含的数量不同,DoubleVector1=[" + doubles1.length + "],DoubleVector2=[" + doubles2.length + "]\n" + "When 'DoubleVector1 innerProduct DoubleVector2', the two vectors of 'DoubleVector' contain different quantities, DoubleVector1=[" + doubles1.length + "], DoubleVector2=[" + doubles2.length + "]")
8678
}
8779

80+
/**
81+
*
82+
* @return 将本对象中存储的向量序列数组拷贝到一个新数组并将新数组返回,这里返回的是一个新数组,支持修改等操作。
83+
*
84+
* Copy the vector sequence array stored in this object to a new array and return the new array. Here, a new array is returned, which supports modification and other operations.
85+
*/
86+
override def copyToNewArray(): Array[Double] = vector.toArray
87+
8888
/**
8989
* @return 该类的实现类对象,用于拓展该接口的子类
9090
*/

src_code/update/1.15_1.16-Chinese.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ![image](https://user-images.githubusercontent.com/113756063/194830221-abe24fcc-484b-4769-b3b7-ec6d8138f436.png) 算法之星-机器大脑
22

3-
- Switch to [English Document](https://github.com/BeardedManZhao/algorithmStar/blob/main/src_code/update/1.14_1.15.md)
3+
- Switch to [English Document](https://github.com/BeardedManZhao/algorithmStar/blob/main/src_code/update/1.15_1.16.md)
44
- knowledge base
55
<a href="https://github.com/BeardedManZhao/algorithmStar/blob/main/KnowledgeDocument/knowledge%20base-Chinese.md">
66
<img src = "https://user-images.githubusercontent.com/113756063/194838003-7ad14dac-b38c-4b57-a942-ba58f00baaf7.png"/>

src_code/update/1.15_1.16.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ![image](https://user-images.githubusercontent.com/113756063/194830221-abe24fcc-484b-4769-b3b7-ec6d8138f436.png) Algorithm Star-MachineBrain
22

3-
- 切换到 [中文文档](https://github.com/BeardedManZhao/algorithmStar/blob/main/src_code/update/1.14_1.15-Chinese.md)
3+
- 切换到 [中文文档](https://github.com/BeardedManZhao/algorithmStar/blob/main/src_code/update/1.15_1.16-Chinese.md)
44
- knowledge base
55
<a href="https://github.com/BeardedManZhao/algorithmStar/blob/main/KnowledgeDocument/knowledge%20base.md">
66
<img src = "https://user-images.githubusercontent.com/113756063/194832492-f8c184c1-55e8-4f16-943a-34b99ac751d4.png"/>

0 commit comments

Comments
 (0)