Hello,
I would like to generate lineprofiles through scaled images
I can generate a
LineROI((20, 20), (40, 0), .1) though it goes from 20 20 to 40 40 in
user coordinates , ?
I would like to click programmatically the ROI button
and then retrieve the XY data array from the ROI plotwidget , what do I
need for this ?
get arrayregion is in weird units...... and the x axis misses
thank you,
yours,
Klaus
last pyqtgraph version from macport
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import division
from PyQt4.QtCore import *
from PyQt4.QtGui import *
#changer les chemins
import numpy as np
import scipy.ndimage as ndi
import pyqtgraph as pg
from pyqtgraph.Point import Point
from open_SQUID_image import open_image_file
from open_SQUID_image import three_points_plain
from open_SQUID_image import slider
from os import path as pt
## Create image to display
class Cross(QDialog):
def __init__(self,parent = None):
QWidget.__init__(self)
self.Form = QWidget()
layout = QVBoxLayout()
self.Form.setLayout(layout)
self.plt = pg.PlotItem()
self.plt.setTitle("swapaxes_scaled")
self.p1 = pg.ImageView(view=self.plt)
# Disconnect old ROI
#imv = pg.image(pg.np.random.normal(size=(100, 100)))
self.p1.roi.sigRegionChanged.disconnect(self.p1.roiChanged)
# Create new ROI and install exactly as done in ImageView.__init__
self.p1.roi = pg.LineROI((20, 20), (40, 0), .1)
self.p1.roi.setZValue(20)
self.p1.view.addItem(self.p1.roi)
self.p1.roi.hide()
self.p1.roi.sigRegionChanged.connect(self.p1.roiChanged)
#self.p2 = pg.PlotWidget()
layout.addWidget(self.p1, 1)
#layout.addWidget(self.p2, 2)
self.data = np.ones((100, 100), dtype=float)
self.data[45:55, 45:55] = 0
self.data[25, :] = 5
self.data[:, 25] = 5
self.data[75, :] = 5
self.data[:, 75] = 5
self.data[50, :] = 10
self.data[:, 50] = 10
self.data += np.sin(np.linspace(0, 20, 100)).reshape(1, 100)
self.data += np.random.normal(size=(100,100))
self.x_length=100
self.y_length=100
self.start_x_mu=1
self.delta_x_mu=0.8
self.start_y_mu=1
self.delta_y_mu=0.5
self.x0, self.x1 = (self.start_x_mu,self.start_x_mu+
self.x_length*self.delta_x_mu)
self.y0, self.y1 = (self.start_y_mu,
self.start_y_mu+self.y_length*self.delta_y_mu)
print "return=X1= {} Y1= {}".format(self.x1,self.y1)
self.xscale, self.yscale = (self.x1-self.x0) / self.data.shape[0],
(self.y1-self.y0) / self.data.shape[1]
print "xscale= {} yscale= {}".format(self.xscale,self.yscale)
print "self.data shape before plotting",self.data.shape
self.p1.setImage(self.data,pos=[self.x0, self.y0],
scale=[self.xscale, self.yscale])
self.plt.setAspectLocked(True)
self.p1.roi.sigRegionChangeFinished.connect(self.updateFromROI)
titi=self.p1.getRoiPlot()
print type(titi)
titi.setVisible(True)
#proxy = pg.SignalProxy(self.plt.scene().sigMouseMoved,
rateLimit=60, slot=self.mouseMoved)
self.Form.show()
def updateFromROI(self):
data,
coords=self.p1.roi.getArrayRegion(self.data,self.plt,(0,1),returnMappedCoords=True)
print "data=", data
print "coord=",coords
--
You received this message because you are subscribed to the Google Groups
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyqtgraph/7284747e-076d-4ab2-af37-094c0d95de7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.