Giter VIP home page Giter VIP logo

Comments (7)

TooTouch avatar TooTouch commented on August 21, 2024

문제점이 생김.

  • resize 한 후 pixel값이 바껴서 각 mask의 class 구분이 되지않음.
  • 각 pixel값이 바뀌지 않은 상태로 resize할 수 있는 방법을 찾아야함.

from 3d_coordconv_segmentation.

TooTouch avatar TooTouch commented on August 21, 2024

resize하기 좋은 image api 두 개.

그 중 PIL을 사용하고 있었으므로 PIL을 사용해서 interpolation을 조정해 보는 걸로.
mask의 경우 interpolation 방법을 nearest neighbor로 해야 각 pixel value가 바뀌지 않고 resize 할 수 있을 것 같다.

PIL

image

Open CV

  • mask의 경우 아래 interpolation 방법 이외에 cv2.INTER_NEAREST을 사용하면 될 듯.
    image

Sample code

#-*- coding:utf-8

import cv2
import numpy as np

img = cv2.imread('images/logo.png')

행 : Height, 열:width

height, width = img.shape[:2]

이미지 축소

shrink = cv2.resize(img, None, fx=0.5, fy=0.5, interpolation=cv2.INTER_AREA)

Manual Size지정

zoom1 = cv2.resize(img, (width2, height2), interpolation=cv2.INTER_CUBIC)

배수 Size지정

zoom2 = cv2.resize(img, None, fx=2, fy=2, interpolation=cv2.INTER_CUBIC)

from 3d_coordconv_segmentation.

TooTouch avatar TooTouch commented on August 21, 2024

Nearest 방법으로 해도 안된다..
원인은 interpolation문제가 아니라 image resize를 하기위한 array to image에서 다시 image to array과정에서 value가 바뀐다.

각 슬라이스별로 같은 label에 대해서 같은 값으로 바뀌면 좋겠지만 이미지를 2D 이미지를 한장씩 슬라이스하면서 변환하다 보니까 각 이미지마다 들어있는 class개수가 다르기때문에 다른 값이 배정된다.

여기에 대한 해결책은 image로 변환하는것없이 단순히 array에서 resize할 수 있는 방법을 찾는 것이다.
아래 github을 참고했음.
https://github.com/Yt-trium/nii-resize/blob/master/nii-resize.py

참고로 image에 대해서는 interpolation이 좋고, mask에 대해서만 array에서 변화하는게 좋음
-> 이유는 시간이 많이 걸리기때문도 있고 api의 resizing이 정보를 덜 잃기(?) 때문이다.

from 3d_coordconv_segmentation.

TooTouch avatar TooTouch commented on August 21, 2024

dltk로 해결!
한 줄이면 resizing 끝.

from 3d_coordconv_segmentation.

TooTouch avatar TooTouch commented on August 21, 2024

MR label directory 9번째 image가 다른 값이 들어가 있음.

  • 421 값을 바꿔줘야함

label: [ 0 205 420 421 500 550 600 820 850]
cnt: [15494952 312719 110267 11667 245762 190593 187564 162053 61639]

from 3d_coordconv_segmentation.

TooTouch avatar TooTouch commented on August 21, 2024

resizing이 끝이 아니였다.
resizing의 문제점은 보다 큰 사이즈를 위해서는 padding으로 resizing이 되는 것이였고, 작은 사이즈를 위해서는 crop되는 문제가 있었다.

그래서 새롭게 코드를 2단계로 구성하여 해결하였다.

  1. padding을 numpy pad를 통해서 3차원 공간에서 바로 padding
  2. scipy.ndimage.zoom을 통해서 ratio를 통해 3차원 공간에서 바로 resizing하였다.
    option으로는 nearest를 주었지만 down sizing이기 때문에 interpolation 과정이 없다고 생각이 된다.
  • (128x128x128) 기준
    결과는 각 이미지당 3.1초 정도 시간이 걸린다.

  • (256x256x256) 기준
    결과는 각 이미지당 3.6초 정도 시간이 걸린다.

from 3d_coordconv_segmentation.

TooTouch avatar TooTouch commented on August 21, 2024

앞으로 해야할 일
augmentation이 추가로 필요하다.

from 3d_coordconv_segmentation.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.