예제 #1
0
    def compute_residual_patch(self, source_z, target_z, out_patch_bbox, mip):
        #print ("Computing residual for {}".format(out_patch_bbox.__str__(mip=0)),
        #        end='', flush=True)
        precrop_patch_bbox = deepcopy(out_patch_bbox)
        precrop_patch_bbox.uncrop(self.crop_amount, mip=mip)

        if mip == self.process_high_mip:
            src_patch = data_handler.get_image_data(self.src_ng_path, source_z,
                                                    precrop_patch_bbox, mip)
        else:
            src_patch = data_handler.get_image_data(self.tmp_ng_path, source_z,
                                                    precrop_patch_bbox, mip)

        tgt_patch = data_handler.get_image_data(self.dst_ng_path, target_z,
                                                precrop_patch_bbox, mip)

        abs_residual = self.net.process(src_patch,
                                        tgt_patch,
                                        mip,
                                        crop=self.crop_amount)
        #rel_residual = precrop_patch_bbox.spoof_x_y_residual(1024, 0, mip=mip,
        #                        crop_amount=self.crop_amount)
        data_handler.save_residual_patch(abs_residual, source_z,
                                         out_patch_bbox, mip,
                                         self.x_res_ng_paths,
                                         self.y_res_ng_paths)
예제 #2
0
    def warp_patch(self, ng_path, z, bbox, res_mip_range, mip):
        influence_bbox = deepcopy(bbox)
        influence_bbox.uncrop(self.max_displacement, mip=0)

        agg_flow = influence_bbox.identity(mip=mip)
        agg_flow = np.expand_dims(agg_flow, axis=0)
        agg_res = data_handler.get_aggregate_rel_flow(
            z, influence_bbox, res_mip_range, mip, self.process_low_mip,
            self.process_high_mip, self.x_res_ng_paths, self.y_res_ng_paths)
        agg_flow += agg_res

        raw_data = data_handler.get_image_data(ng_path, z, influence_bbox, mip)
        #no need to warp if flow is identity
        #warp introduces noise
        if not influence_bbox.is_identity_flow(agg_flow, mip=mip):
            warped = warp(raw_data, agg_flow)
        else:
            #print ("not warping")
            warped = raw_data[0]

        mip_disp = int(self.max_displacement / 2**mip)
        cropped = crop(warped, mip_disp)
        result = data_handler.preprocess_data(cropped * 256)
        #preprocess divides by 256 and puts it into right dimensions
        #this data range is good already, so mult by 256
        data_handler.save_image_patch(self.dst_ng_path, result, z, bbox, mip)
예제 #3
0
 def chunkwise(patch_bbox):
     raw_patch = data_handler.get_image_data(source, z, patch_bbox, mip)
     data_handler.save_image_patch(dest, raw_patch, z, patch_bbox, mip)
예제 #4
0
 def downsample_patch(self, ng_path, z, bbox, mip):
     in_data = data_handler.get_image_data(ng_path, z, bbox, mip - 1)
     result = downsample_mip(in_data)
     return result