Example #1
0
def part_image(image_path):
    image = cv2.imread(image_path)
    width = image.shape[0]
    height = image.shape[1]
    bin_array = np.zeros((width, height), np.uint8)
    img = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    U, T = rof.denoise(img, img, tolerance=0.001)
    t = 0.8  # flower32_t0 threshold
    seg_im = U < t * U.max()
    for wid in range(0, width):
        for hei in range(0, height):
            bin_array[wid][hei] = cvt(seg_im[wid][hei]) * img[wid][hei]
    cv2.imshow("image", bin_array)
    cv2.waitKey(0)
    return bin_array
Example #2
0
from PIL import Image
from numpy import *
from scipy.misc import imsave

from PCV.tools import rof

"""
Simple example of Chan-Vese segmentation from Section 9.3.
Load an image, segment in two classes and save result.
"""

im = array(Image.open('../data/houses.png').convert('L')) 
U,T = rof.denoise(im,im,tolerance=0.001)
t = 0.4

imsave('result.pdf',U < t*U.max())
Example #3
0
from PIL import Image
from pylab import *
import numpy as np
from scipy.ndimage import filters
from PCV.tools import rof

im = np.asarray(Image.open('1.jpeg').convert('L'))
U, T = rof.denoise(im, im)
G = filters.gaussian_filter(im, 3)

figure()
gray()

subplot(131)
imshow(im)

subplot(132)
imshow(G)

subplot(133)
imshow(U)

show()
Example #4
0
from MVR import stereo

from PIL import Image
import numpy
# import rof
from PCV.tools import rof

im_l = numpy.array(
    Image.open('dataset_tsukuba/scene1.row3.col3.ppm').convert('L'), 'f')
im_r = numpy.array(
    Image.open('dataset_tsukuba/scene1.row3.col4.ppm').convert('L'), 'f')

steps = 15
start = 1
wid = 3

res = stereo.plane_sweep_gauss(im_l, im_r, start, steps, wid)

res, _ = rof.denoise(res, res, tv_weight=80 / 255.0, tolerance=0.01)

import scipy.misc
scipy.misc.imsave('dataset_tsukuba/out_depth_rof.png', res)
from pylab import *
from numpy import *
from numpy import random
from scipy.ndimage import filters
from scipy.misc import imsave
from PCV.tools import rof

""" This is the de-noising example using ROF in Section 1.5. """

# 添加中文字体支持
from matplotlib.font_manager import FontProperties
font = FontProperties(fname=r"c:\windows\fonts\SimSun.ttc", size=14)

im = array(Image.open('../data/empire.jpg').convert('L'))

U,T = rof.denoise(im,im)
G = filters.gaussian_filter(im,10)


# save the result
#imsave('synth_original.pdf',im)
#imsave('synth_rof.pdf',U)
#imsave('synth_gaussian.pdf',G)


# plot
figure()
gray()

subplot(1,3,1)
imshow(im)
Example #6
0
from PCV.tools import rof
from pylab import *
from PIL import Image
import scipy.misc

#im = array(Image.open('../data/ceramic-houses_t0.png').convert("L"))
im = array(Image.open('../data/flower32_t0.png').convert("L"))
figure()
gray()
subplot(131)
axis('off')
imshow(im)

U, T = rof.denoise(im, im, tolerance=0.001)
subplot(132)
axis('off')
imshow(U)

#t = 0.4  # ceramic-houses_t0 threshold
t = 0.8  # flower32_t0 threshold
seg_im = U < t * U.max()
#scipy.misc.imsave('ceramic-houses_t0_result.pdf', seg_im)
scipy.misc.imsave('flower32_t0_result.pdf', seg_im)
subplot(133)
axis('off')
imshow(seg_im)

show()