类似于以下内容......除了让它工作:
public void seeBMPImage(String BMPFileName) throws IOException {
BufferedImage image = ImageIO.read(getClass().getResource(BMPFileName));
int[][] array2D = new int[66][66];
for (int xPixel = 0; xPixel < array2D.length; xPixel++)
{
for (int yPixel = 0; yPixel < array2D[xPixel].length; yPixel++)
{
int color = image.getRGB(xPixel, yPixel);
if ((color >> 23) == 1) {
array2D[xPixel][yPixel] = 1;
} else {
array2D[xPixel][yPixel] = 1;
}
}
}
}
Run Code Online (Sandbox Code Playgroud) 我用Java构建了一个图像分类器,我想针对这里提供的图像进行测试:http://yann.lecun.com/exdb/mnist/
不幸的是,如果您下载train-images-idx3-ubyte.gz或任何其他3个文件,它们都是文件类型:.idx1-ubyte
第一个问题:我想知道是否有人可以给我关于如何将.idx1-ubyte转换为位图(.bmp)文件的说明?
第二个问题:或者我一般如何阅读这些文件?
有关IDX文件格式的信息:IDX文件格式是各种数字类型的向量和多维矩阵的简单格式.基本格式是:
magic number
size in dimension 0
size in dimension 1
size in dimension 2
.....
size in dimension N
data
Run Code Online (Sandbox Code Playgroud)
幻数是一个整数(MSB优先).前2个字节始终为0.
第三个字节编码数据的类型:
0x08: unsigned byte
0x09: signed byte
0x0B: short (2 bytes)
0x0C: int (4 bytes)
0x0D: float (4 bytes)
0x0E: double (8 bytes)
Run Code Online (Sandbox Code Playgroud)
第4个字节编码向量/矩阵的维数:1表示向量,2表示矩阵....
每个维度的大小为4字节整数(MSB优先,高端,与大多数非英特尔处理器一样).
数据存储在C数组中,即最后一维中的索引变化最快.
我在Java中有以下类.我希望能够将它保存为一个通用的文件格式,可以在不同的PC上移动.我知道对象序列化但我想知道我的其他选择是什么以及它们各自的优缺点是什么.谢谢!例如,序列化文件不是人类可读的,因此是骗局.
public class NervousSystem {
private CentralNervousSystem CNS;
private PeripheralNervousSystem PNS;
public NervousSystem(Neocortex neocortex, LateralGeniculateNucleus LGN, Retina retina) {
this.CNS = new CentralNervousSystem(neocortex, LGN);
this.PNS = new PeripheralNervousSystem(retina);
}
public CentralNervousSystem getCNS() {
return this.CNS;
}
public PeripheralNervousSystem getPNS() {
return this.PNS;
}
}
Run Code Online (Sandbox Code Playgroud) 所以现在我的项目中有以下标准包名称设置:
src/main/java/model/SampleClass.java 可以查看@ https://github.com/quinnliu/WalnutiQ/blob/master/src/main/java/model/SampleClass.java
src/test/java/model/SampleClassTest.java 可以查看@ https://github.com/quinnliu/WalnutiQ/blob/master/src/test/java/model/SampleClassTest.java
SampleClass.java 看起来像这样:
package main.java.model;
public class SampleClass {
int packagePrivateMethod() {
return -1;
}
}
Run Code Online (Sandbox Code Playgroud)
SampleClassTest.java 看起来像这样:
package test.java.model;
import main.java.model.SampleClass;
public class SampleClassTest extends junit.framework.TestCase {
private SampleClass sampleClass;
public void setUp() {
this.sampleClass = new SampleClass();
}
public void test_packagePrivateMethod() {
// this method can't be called right now why?
//this.sampleClass.packagePrivateMethod();
}
}
Run Code Online (Sandbox Code Playgroud)
为什么不能调用packagePrivateMethod()方法???
我收到上述错误,这里的答案没有帮助.
基本上我似乎无法运行我用Java编译的文件.我试图运行的文件HowMARK_II_FitsInBrainAnatomy.java就在这里
我使用以下命令在末尾:.的-cp参数中编译所有需要的.jars和当前目录:
javac -cp /home/ugrads/majors/quinnliu/workspace/WalnutiQ/build/libs/WalnutiQ.jar:/home/ugrads/majors/quinnliu/workspace/WalnutiQ/referencedLibraries/gson-2.2.4.jar:. HowMARK_II_FitsInToBrainAnatomy.java
所以在我使用上面的命令后,我创建了编译文件HowMARK_II_FitsInToBrainAnatomy.class但是运行该文件的以下命令在这个问题的标题中给出了ERROR:
java -cp /home/ugrads/majors/quinnliu/workspace/WalnutiQ/build/libs/WalnutiQ.jar:/home/ugrads/majors/quinnliu/workspace/WalnutiQ/referencedLibraries/gson-2.2.4.jar:. model.MARK_II.vision.HowMARK_II_FitsInToBrainAnatomy
当我加入:.我的时候,我看不出我做错了什么-cp
如何返回指向char数组中间某些内容的指针?
// Returns a pointer to the first occurrence of the given character in the
// given string.
const char* strchr(const char* string, char charToFind) {
for (int i = 0; i < strlen(string); i++) {
if (string[i] == charToFind) {
return string[i]; // <== THIS IS WRONG, How do I fix this?
}
}
return '\0';
}
Run Code Online (Sandbox Code Playgroud) 嗨,我当前的构建正在传递中,您可以在这里查看:https : //travis-ci.org/quinnliu/WalnutiQ
但是,如果您在这里转到我的存储库:https : //github.com/quinnliu/WalnutiQ
并查看travis CI状态栏,它仍然显示存在构建错误。我怎样才能解决这个问题?
所以我有下表:
qliu=# select id from api_member;
id
-----
242
236
246
251
253
9
21
185
49
188
Run Code Online (Sandbox Code Playgroud)
我希望能够使用以下命令删除具有一系列ID的行:
delete from api_member where id between '0' and '10';
Run Code Online (Sandbox Code Playgroud)
但它什么都没删除.如果你想知道的话
delete from api_member where id between 0 and 10;
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Run Code Online (Sandbox Code Playgroud)ERROR: operator does not exist: character varying >= integer LINE 1: delete from api_member where id between 0 and 10; ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
我试图使用react-day-Pickers组件,但我无法弄清楚如何导入.css文件,我不断收到错误:
Module parse failed:
/Users/qliu/Documents/workspace/AppNexus/pricing_ui/contract-ui/app_contract-ui/node_modules/react-day-picker/lib/style.css Unexpected token (3:0)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (3:0)
Run Code Online (Sandbox Code Playgroud)
我已经"css-loader": "^0.19.0",安装了package.json,这里是我的Calender.jsx文件:
import React from "react";
import DayPicker, { DateUtils } from "react-day-picker";
import "../../../node_modules/react-day-picker/lib/style.css"; // <==== ERROR ON THIS LINE
export default class Calender extends React.Component {
state = {
selectedDay: null
};
handleDayClick(e, day, modifiers) {
if (modifiers.indexOf("disabled") > -1) {
console.log("User clicked a disabled day.");
return;
}
this.setState({
selectedDay: day
});
} …Run Code Online (Sandbox Code Playgroud) 我在 Python 中有以下函数,似乎可以正常工作:
def test(self):
x = -1
# why don't I need to initialize y = 0 here?
if (x < 0):
y = 23
return y
Run Code Online (Sandbox Code Playgroud)
但要使其工作,为什么我不需要初始化变量 y?我以为 Python 具有块作用域,那么这怎么可能呢?