--- Title: hogeoge enhancer Author: yamasyuh68 Web: https://mimemo.io/m/WrRz7l7nbvoNaA6 --- # sip 使うか?? sip voidptr https://www.riverbankcomputing.com/static/Docs/sip/python_api.html class sip.voidptr __getitem__(idx) → item This returns the item at a given index. An exception will be raised if the address does not have an associated size. In this way it behaves like a Python memoryview object. idx – is the index which may either be an integer, an object that implements __index__() or a slice object. Returns: the item. If the index is an integer then the item will be a Python v2 string object or a Python v3 bytes object containing the single byte at that index. If the index is a slice object then the item will be a new voidptr object defining the subset of the memory corresponding to the slice. __setitem__(idx, item) setsize(size) Returns:True if the memory is writeable. asarray([size=-1]) → :class:`sip.array` This returned the block of memory as a sip.array object. The memory is not copied. Parameters:size – the size of the array. If it is negative then the size associated with the address is used. If there is no associated size then an exception is raised. Returns:the sip.array object. # スクロールの実装 QScrollAreaの罠にハマる https://dungeonneko.hatenablog.com/entry/2016/02/09/015220 【QScrolArea】中身のサイズに応じてスクロールバーを表示する https://dnaga392.hatenablog.com/entry/2015/05/15/124816 ------------------------- QScrollAreaの使い方 http://qt-log.open-memo.net/sub/scroll-area--usage-of-scrollarea.html QScrollArea * scrollArea = new QScrollArea(); scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); ///常に垂直なスクロールバーを表示 scrollArea.setWidget(new QLabel("Small Text")); ------------------------- 公式ドキュメント QLabel *imageLabel = new QLabel; QImage image("happyguy.png"); imageLabel->setPixmap(QPixmap.fromImage(image)); scrollArea = new QScrollArea; scrollArea->setBackgroundRole(QPalette.Dark); scrollArea->setWidget(imageLabel); ``` # __init__ # PyQt5.QtWidgets.QScrollArea # QLayout sa=QScrollArea() # sa.setBackgroundRole(QPalette.Dark) # sa.setVerticalScrollBarPolicy(Qt.BarAlwaysOn) sa.setWidget(label) sa.widgetResizable(True) label.layout().setSizeConstraint( QLayout.SetMinimumSize ) # in sbclass , move by mouse mouseMoveEvent(QMouseEvent) mousePressEvent(QMouseEvent) mouseReleaseEvent(QMouseEvent) sa.verticalScrollBar.setValue() # QScrollBar verticalScrollBar (self) # QScrollBar horizontalScrollBar # setValue (self, int) ``` ---- # ホワイトポイント補正の延長 今は白に補正しているが、任意の色に補正したい(肌色を保存しておきたい) HSV全て調節できるようにしたい - 任意のポイントを特定色に変える 人間の頬のいろを合わせるとか - ヒストグラムの頂上を合わせるルーチンがあったのでそれ変形は? カラーを二つ渡したら色毎に変換テーブルを作って、画像を変換してself.enhanced にセットして描画する ルーチンを作る ``` def convertcolor(self,c1,c2) : # arg-->QColor c1=[c1.red(),c1.green(),c1.blue()] c2=[c2.red(),c2.green(),c2.blue()] c1=[120,180,50] # original color c2=[150,50,200] # target color v=[ [ c2[i] /c1[i] , (255-c2[i]) / (255-c1[i]) , 255*(1-((255-c2[i]) / (255-c1[i]))) ] for i in range(3)] t=[ [round(i*v[l][1]) if i < c1[l] else round(i*v[l][1]+v[l][2]) for i in range(256)] for l in range(3) ] ``` - これで変換テーブルは出来たから後は描画するだけのはず - しかし、色変換は色相は維持されない、ピンポイント近くの色はうまく変換されるが他の色はおかしくなるような?? 白変換だからうまくいくのではないだろうか? --- # ヒストグラムの単純な平行移動ルーチンを作りたい ``` # 初期化 self.LUT = [ [i for i in range(256)] for l in range(3) ] # 平行移動 +a # スライダー置いてコネクト、0-300、150に設定 def parallel( self , a ): a = a-150 if a > 0 : self.LUT[0] = [i+a if i+a <256 else 255 for i in range(256) ] self.LUT[0][0]=0 else : self.LUT[1] = [i+a if i+a >0 else 0 for i in range(256) ] ``` ---- # ベジェ曲線の座標の求め方について - Qtはベジェ曲線を描画しているのだから座標も持ってるはずだと思いドキュメントを見てみたらこんなメッソドがあった QPointF QPainterPath.pointAtPercent (self, float t) このtは0-1で指定することになっていて、ベジェそのものですね - Qtもあくまでtベースでしか値は返してくれないって事だな 内部的にはどういう実装なんだろう? 曲線とは言ってもPCだから全てはドットの描画でしかないはずだ でもドットだとx値が飛ぶところでは間が空くはずだ でもパスだからどんなに拡大しても綺麗に描画出来るように実装されてるはずだ やはり全てのx値を計算して求めてるんだろうか? だとしたらそういう関数を用意してくれても良いと思うんだが・・・ - 今は自分でx,yを求めてるが、Qtの関数を使ってみるか??? 結果が同じかどうかを調べてみるとか・・・ 意味ないかな? ---- → [戻る PyQt で画像のビューア](https://mimemo.io/m/QORbW4qkvOoda0N)