Home > database >  I want to create a list from rows and column of a picture
I want to create a list from rows and column of a picture

Time:11-01

I have a 2D binary video with a value of 0 or 255. I would like to find the pixels with a value of 255 in a specific range of rows and columns in each image and plot the column value of them continuously. I found the rows (x values) and columns (y values) of pixels with a value of 255 in the following program, however I cannot create a list of rows and a list of columns separately to plot the column values continuously. Please find below my program.

for row in range(0,700):
        for column in range(354):
            if thresh[row][column]==255:
                print(row,column)

Could you please help me to create a list of row values and column values separately and plot them continuously using matplotlib?

CodePudding user response:

Let's use a simple matrix as an example:

A = [[1, 255, 5], 
    [-5, 8, 9]]
        

The objective is to print indices with a value of 255.

for i in range(len(A)):
    for j in range(len(A[i])):
        if A[i][j]==255:
            print(i,j)

Which returns 0 1 in this case.

  • Related