Home Python OpenCV: Reading an image along x and y axis
Reply: 0

Python OpenCV: Reading an image along x and y axis

user7541
1#
user7541 Published in September 19, 2018, 11:24 am

Aim: I am trying to read the first point (non-zero) here in this image (shown as the red arrow)

from __future__ import division
import numpy as np

import cv2
im1 = cv2.imread('C:/Users/Desktop/Line.png', 0)
for x in range(0, im1.shape[0], 1):
    for y in range(0, im1.shape[1], 1):
        cpt = im1[x][y]
        if 0 < cpt <= 255 :
           print("This is the value", x,y)

But, the point being printed is this (a zero point):

How is this so?

The original image:

share|improve this question
  • Post a clean source image please.And you method is ineffecient. – Silencer Apr 16 at 11:16
  • I have added the source image here. – Jeremy Apr 16 at 11:20
  • With your code i get (91, 387) what are you getting? BTW, even though your code may be correct, x is actually the row and y is the col... in cartesian coordinates it will be (91, 387) but as you are printing it is the other way around – api55 Apr 16 at 11:22

1 Answer 1

active oldest votes
up vote 1 down vote accepted
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.470125 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO