MCPcopy Create free account
hub / github.com/IceClear/StableSR / __init__

Method __init__

scripts/util_image.py:610–633  ·  view source on GitHub ↗

Input: im: h x w x c, numpy array, [0, 1], low-resolution image in SR pch_size, stride: patch setting sf: scale factor in image super-resolution

(self, im, pch_size, stride, sf=1)

Source from the content-addressed store, hash-verified

608
609class ImageSpliterNp:
610 def __init__(self, im, pch_size, stride, sf=1):
611 '''
612 Input:
613 im: h x w x c, numpy array, [0, 1], low-resolution image in SR
614 pch_size, stride: patch setting
615 sf: scale factor in image super-resolution
616 '''
617 assert stride <= pch_size
618 self.stride = stride
619 self.pch_size = pch_size
620 self.sf = sf
621
622 if im.ndim == 2:
623 im = im[:, :, None]
624
625 height, width, chn = im.shape
626 self.height_starts_list = self.extract_starts(height)
627 self.width_starts_list = self.extract_starts(width)
628 self.length = self.__len__()
629 self.num_pchs = 0
630
631 self.im_ori = im
632 self.im_res = np.zeros([height*sf, width*sf, chn], dtype=im.dtype)
633 self.pixel_count = np.zeros([height*sf, width*sf, chn], dtype=im.dtype)
634
635 def extract_starts(self, length):
636 starts = list(range(0, length, self.stride))

Callers

nothing calls this directly

Calls 2

extract_startsMethod · 0.95
__len__Method · 0.95

Tested by

no test coverage detected