qurit / qurit/rt-utils

use_pin_hole (x,y) vs (y,x)

Open
#115 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
256
Forks
75
PR merge metrics
No merged PRs in 30d

Description

I had problems with the use_pin_hole option. It worked fine on the test data but not on some real world data (kidney segmentations)
I figured the test data was symmetric on y=x.

The problem seems to come from image_help.py, def draw_line_upwards_from_point.

I had to make some changes to (x,y) to (y,x) and back, to get it working on my data.

def draw_line_upwards_from_point(
mask: np.ndarray, start, fill_value: int
) -> np.ndarray:
line_width = 2
end = (start[1], start[0]-1) # np.ndarray and opencv expects (x,y) vs (y,x)
#start = (end[0], end[1])
mask = mask.astype(np.uint8) # Type that OpenCV expects
# Draw one point at a time until we hit a point that already has the desired value
while mask[end] != fill_value:
#cv.line(mask, start, end, fill_value, line_width) # skipped, no need to draw each step
#print("debug",start,end,mask[end],fill_value)
# Update end to the next position
#start = end
end = (end[0]- line_width, end[1])
cv.line(mask, start, (end[1],end[0]), fill_value, line_width) # np.ndarray and opencv expects (x,y) vs (y,x)
#plt.imshow(mask)
#plt.show()
return mask.astype(bool)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue points to image_help.py and draw_line_upwards_from_point; first inspect the coordinate conventions used by the mask and OpenCV calls, then reproduce the use_pin_hole case with nonsymmetric data. Done means the function handles (x,y) and (y,x) consistently and use_pin_hole works for kidney segmentations without manual coordinate swaps.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, opencv, python
Domain
computer-vision
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.