我是 Python 新手,我正在尝试执行官方页面上显示的教程。我的目标是,使用本地大津阈值方法分析我创建的图片。
带有示例图片的代码工作正常,但我想读取一个自定义图像,该图像与*.py-file存储在同一目录中。
这是代码:
from skimage import data
from skimage.morphology import disk
from skimage.filters import threshold_otsu, rank
from skimage.util import img_as_ubyte
import matplotlib
import matplotlib.pyplot as plt
matplotlib.rcParams['font.size'] = 9
img = img_as_ubyte(data.page())
radius = 15
selem = disk(radius)
local_otsu = rank.otsu(img, selem)
threshold_global_otsu = threshold_otsu(img)
global_otsu = img >= threshold_global_otsu
fig, ax = plt.subplots(2, 2, figsize=(8, 5), sharex=True, sharey=True,
subplot_kw={'adjustable': 'box-forced'})
ax0, ax1, ax2, ax3 = ax.ravel()
fig.colorbar(ax0.imshow(img, cmap=plt.cm.gray),
ax=ax0, orientation='horizontal')
ax0.set_title('Original')
ax0.axis('off')
fig.colorbar(ax1.imshow(local_otsu, cmap=plt.cm.gray),
ax=ax1, …Run Code Online (Sandbox Code Playgroud) 我已经按照本教程使用JBoss AS 7设置MySQL.不幸的是,服务器挂起了消息:
INFO [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-1) Starting Coyote HTTP/1.1 on http--127.0.0.1-8080
Run Code Online (Sandbox Code Playgroud)
没有任何反应.
什么可能导致这个问题?
完整日志:
=========================================================================
JBoss Bootstrap Environment
JBOSS_HOME: /Applications/JBoss
JAVA: /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/bin/java
JAVA_OPTS: -server -XX:+UseCompressedOops -XX:+TieredCompilation -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.server.default.config=standalone.xml
=========================================================================
11:42:35,759 INFORMATION [org.jboss.modules] JBoss Modules version 1.1.1.GA
11:42:36,067 INFO [org.jboss.msc] JBoss MSC version 1.0.2.GA
11:42:36,139 INFO [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting
11:42:37,280 INFO [org.xnio] XNIO Version 3.0.3.GA
11:42:37,294 INFO [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA
11:42:37,292 …Run Code Online (Sandbox Code Playgroud) 我构建了一个FileDialog并在用户选择其中的文件后,应使用文件名更新标签.这就是我所拥有的:
Button buttonSelectFile;
fileFilterPath = "C:/";
Label myDir;
fileSelectionLabel = new Label(container, SWT.None | SWT.WRAP);
fileSelectionLabel.setText("Path to file");
buttonSelectFile = new Button(container, SWT.PUSH);
buttonSelectFile.setText("Select file");
buttonSelectFile.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
Shell shell = new Shell();
FileDialog fileDialog = new FileDialog(shell, SWT.MULTI);
fileDialog.setFilterPath(fileFilterPath);
fileDialog.setFilterExtensions(new String[] { "*.exe" });
fileDialog.setFilterNames(new String[] { "exe-files" });
String files = fileDialog.open();
if (files != null) {
fileFilterPath = fileDialog.getFilterPath();
selectedFile = fileDialog.getFileName();
StringBuffer sb = new StringBuffer(
"Selected …Run Code Online (Sandbox Code Playgroud) 我正在从Python中的ASCII文件中提取一些值,我想使用matplotlib将其用于绘图中的标签.所以其中一个字符串是µm/m.Python字符串中提取的值是\xb5m/m使用Eclipse内部的调试器?m/m.
因此,当将标签传递给matplotlib时,它会显示以下错误:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 21: ordinal not in range(128)
Run Code Online (Sandbox Code Playgroud)
所以它似乎是一个编码问题.我尝试将以下行添加到我的班级顶部:
# -*- coding: utf-8 -*-
Run Code Online (Sandbox Code Playgroud)
不幸的是,这并没有解决问题.我错过了什么吗?
我正在尝试使用 Python 2.7 中的路径
这就是我在主课中尝试做的事情:
program = MyProgram()
program.doSomething('C:\Eclipse\workspace\MyProgram\files\12345678_Testing1_ABCD005_Static_2214_File12.txt')
Run Code Online (Sandbox Code Playgroud)
在函数内部,doSomething(filePath)字符串已经如下所示:
所以有一种特殊字符加上一些字符被完全删除。什么可能导致这个问题?
在我的内心p:dataTable,我试图只渲染我需要的行.码:
<h:form id="f">
<p:dataTable var="order"
value="#{mbOrderController.ordersList}">
<f:facet name="header">#{msg.orders}</f:facet>
<p:column sortBy="#{order.orderNr}"
headerText="#{msg.order_number}">
<p:outputLabel value="#{order.orderNr}"
rendered="#{order.type.label == 'Shoes'}" />
</p:column>
<p:column sortBy="#{order.date}" headerText="#{msg.date}">
<p:outputLabel value="#{order.date}">
<f:convertDateTime pattern="dd.MM.yy" />
</p:outputLabel>
</p:column>
<p:column sortBy="#{order.type.label}" headerText="#{msg.type}">
<p:outputLabel value="#{order.type.label}" />
</p:column>
</p:dataTable>
</h:form>
Run Code Online (Sandbox Code Playgroud)
订单类型标签(第三列)是一个Enumeration,可以是"鞋子","衬衫"或"裤子".我只想显示带有"Shoes"的行.
试图将rendered属性添加到第一个p:outputLabel当然只隐藏此输出标签的属性.如果我将该rendered属性添加到p:outputLabel表中的每个属性,则表中的最低行仍然可见,尽管所有单元格都是空的:
如何使用显示的rendered属性仅显示特定行?有人可以帮忙吗?
我有一个primefaces面板,我想在其中p:fileUploader为几个元素提供primefaces 。在运行期间,不清楚会有多少项目。这是我的代码:
<h:form>
<p:panel id="grid" header="">
<h:panelGrid columns="2" cellpadding="5">
<c:forEach items="${bean.testCurrent}"
var="car" varStatus="i">
<p:outputLabel value="#{car.name}: " for="image${i.index}" />
<p:column>
<p:fileUpload id="image${i.index}"
fileUploadListener="#{bean.uploadImage}"
mode="advanced" dragDropSupport="true" multiple="false"
update="messages" sizeLimit="1000000"
allowTypes="/(\.|\/)(gif|jpe?g|png)$/"
oncomplete="disableChoosing()"/>
<p:growl id="growl" showDetail="true" />
</p:column>
</c:forEach>
</h:panelGrid>
<p:commandButtonaction="#{bean.save()}" value="Save" />
<p:commandButton action="#{bean.cancel()}" value="Cancel" />
</p:panel>
</h:form>
Run Code Online (Sandbox Code Playgroud)
所以我的第一步是用 JSTL 的c:forEach. 这不起作用,因为 JSTL 在视图的构建期间运行,而 JSF 在视图组件树的渲染期间运行。
是否有可能在面板中实现 for 循环,或者是否有其他可能动态显示表单元素?
我的Eclipse应用程序中有一个简单的swt GUI,如下所示:
它的实现非常简单:
// creating the label
Label label = new Label(composite, SWT.NONE);
label.setText("Label");
// creating the input field
Text text = new Text(composite, SWT.BORDER);
gridData.horizontalAlignment = SWT.FILL;
gridData.grabExcessHorizontalSpace = true;
text.setLayoutData(gridData);
Run Code Online (Sandbox Code Playgroud)
我想在标签和输入元素之间添加一个按钮,以便用户可以获得有关在字段内添加内容的其他帮助.
它可以是帮助按钮,也可以只是一个显示鼠标悬停信息的图标.
我该如何实现?我将不胜感激任何帮助!
java ×3
python ×3
jsf ×2
primefaces ×2
string ×2
swt ×2
datasource ×1
datatable ×1
eclipse ×1
filesystems ×1
for-loop ×1
forms ×1
image ×1
jboss ×1
jdbc ×1
jsf-2 ×1
jstl ×1
label ×1
matplotlib ×1
mysql ×1
python-2.7 ×1
row ×1
scikit-image ×1
threshold ×1
unicode ×1