Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
335 views
in Technique[技术] by (71.8m points)

image processing - pyqtgraph LUT histogram element how to apply same transform to the numpy array separately

I made a GUI to edit an image(16 bit grayscale) , everything looks good in the GUI but I need to repeat a step the GUI does for me on my own, I used pyqtgraph... the imageview widget provides a histogram feature

if I move the yellow bars, I can change the maximum and minimum intensity range, in this case from 1500 to 10000 would make the image visible in this case.

I need to repeat that step of processing the image without using using the GUI,I took a look at the source code, and it mentions a look up table(LUT) to perform the calculation, yet I didn't comprehend the code enough to find where that step is being down and trying to implement it myself.

any help on how to apply a Look up table transformation to a 16 bit image would be helpful

import sys
import cv2
import numpy as np
import pyqtgraph as pg
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import pco
from PyQt5.QtWidgets import QScrollArea
import time

class MainWindow(QWidget):
    def __init__(self):
        super().__init__()

        self.initUI()
                    
    def initUI(self):
        img_tif = cv2.imread("my_file.tif",cv2.IMREAD_ANYDEPTH)
        img_tifr = cv2.rotate(img_tif, cv2.ROTATE_90_COUNTERCLOCKWISE)
        img = np.asarray(img_tifr)
        self.image = pg.image()
        self.image.getHistogramWidget().setLevels(0,50000)
        self.image.ui.menuBtn.hide()
        self.image.ui.roiBtn.hide()
        self.image.setImage(img)

def main():

    app = QApplication(sys.argv)
    main_window = MainWindow()
    app.exec_()
    sys.exit(0)

if __name__ == '__main__':
    main()
question from:https://stackoverflow.com/questions/66058820/pyqtgraph-lut-histogram-element-how-to-apply-same-transform-to-the-numpy-array-s

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I ended up finding an answer, by following this

How to convert a 16 bit to an 8 bit image in OpenCV?

hope it helps anyone else


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...