Draw inliers for debugging purposes.  Need to convert from normalized to pixel coordinates.
509600
public static void drawInliers(BufferedImage left, BufferedImage right, CameraPinholeBrown intrinsic,
								   List<AssociatedPair> normalized) {
		Point2Transform2_F64 n_to_p = LensDistortionFactory.narrow(intrinsic).distort_F64(false,true);

		List<AssociatedPair> pixels = new ArrayList<>();

		for (AssociatedPair n : normalized) {
			AssociatedPair p = new AssociatedPair();

			n_to_p.compute(n.p1.x, n.p1.y, p.p1);
			n_to_p.compute(n.p2.x, n.p2.y, p.p2);

			pixels.add(p);
		}

		// display the results
		AssociationPanel panel = new AssociationPanel(20);
		panel.setAssociation(pixels);
		panel.setImages(left, right);

		ShowImages.showWindow(panel, "Inlier Features", true);
	}
972650
def pix2canvas(self, pt):
        
        x, y = pt[:2]
        #print('p2c in', x, y)
        mm = gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX)
        pm = gl.glGetDoublev(gl.GL_PROJECTION_MATRIX)
        vp = gl.glGetIntegerv(gl.GL_VIEWPORT)

        win_x, win_y = float(x), float(vp[3] - y)
        win_z = gl.glReadPixels(int(win_x), int(win_y), 1, 1,
                                gl.GL_DEPTH_COMPONENT, gl.GL_FLOAT)
        pos = glu.gluUnProject(win_x, win_y, win_z, mm, pm, vp)
        #print('out', pos)
        return pos
813930
function visualizeOutputs(
    partId, drawHeatmaps, drawOffsetVectors, drawDisplacements, ctx) {
  const {heatmapScores, offsets, displacementFwd, displacementBwd} =
      modelOutputs;
  const outputStride = +guiState.outputStride;

  const [height, width] = heatmapScores.shape;

  ctx.globalAlpha = 0;
  const heatmapScoresArr = heatmapScores.arraySync();
  const offsetsArr = offsets.arraySync();

  for (let y = 0; y < height; y++) {
    for (let x = 0; x < width; x++) {
      const score = heatmapScoresArr[y][x][partId];

      // to save on performance, don't draw anything with a low score.
      if (score < 0.05) continue;

      // set opacity of drawn elements based on the score
      ctx.globalAlpha = score;

      if (drawHeatmaps) {
        drawPoint(ctx, y * outputStride, x * outputStride, 2, 'yellow');
      }

      const offsetsVectorY = offsetsArr[y][x][partId];
      const offsetsVectorX = offsetsArr[y][x][partId + 17];

      if (drawOffsetVectors) {
        drawOffsetVector(
            ctx, y, x, outputStride, offsetsVectorY, offsetsVectorX);
      }

      if (drawDisplacements) {
        // exponentially affect the alpha of the displacements;
        ctx.globalAlpha *= score;

        drawDisplacementEdgesFrom(
            ctx, partId, displacementFwd, outputStride, parentToChildEdges, y,
            x, offsetsVectorY, offsetsVectorX);

        drawDisplacementEdgesFrom(
            ctx, partId, displacementBwd, outputStride, childToParentEdges, y,
            x, offsetsVectorY, offsetsVectorX);
      }
    }

    ctx.globalAlpha = 1;
  }
}
245082
def draw(self):
        '''
        
        '''
        observed_arr = None
        for result_tuple in self.__feature_generator.generate():
            observed_arr = result_tuple[0]
            break

        observed_arr = observed_arr.astype(float)
        if self.__norm_mode == "z_score":
            if observed_arr.std() != 0:
                observed_arr = (observed_arr - observed_arr.mean()) / observed_arr.std()
        elif self.__norm_mode == "min_max":
            if (observed_arr.max() - observed_arr.min()) != 0:
                observed_arr = (observed_arr - observed_arr.min()) / (observed_arr.max() - observed_arr.min())
        elif self.__norm_mode == "tanh":
            observed_arr = np.tanh(observed_arr)

        return observed_arr
669327
def draw_variable_local(self, size): 
        
        return ss.norm.rvs(loc=self.mu0, scale=self.sigma0, size=size)
702624
function (d, context) {
                    dimple._drawMarkers(d, chart, series, duration, className, graded, onEnter(d), onLeave(d), context);
                }
501351
function draw(c, frame)
{
    const pixels = frame.data
    for (let y = 0; y < frame.height; y++)
    {
        for (let x = 0; x < frame.width; x++)
        {
            const color = pixels[x + y * frame.width]
            if (typeof color !== 'undefined')
            {
                let hex = color.toString(16)
                while (hex.length < 6)
                {
                    hex = '0' + hex
                }
                c.fillStyle = '#' + hex
                c.beginPath()
                c.fillRect(x, y, 1, 1)
            }
        }
    }
}
375919
def inpaint(self):
        

        import inpaint
        filled = inpaint.replace_nans(np.ma.filled(self.raster_data, np.NAN).astype(np.float32), 3, 0.01, 2)
        self.raster_data = np.ma.masked_invalid(filled)
1133076
def contours(*values)
		(values = (0..values[0]+1).to_a.map{|i| i.to_f * (@grid.max - @grid.min) / ( values[0]+1) + @grid.min}; values.pop; values.shift) if values.size==1 and values[0].kind_of? Integer
		cons = values.inject({}){|hash, val| hash[val] = []; hash}
		get_startpoints(cons)
		#@analysed = {}
		@found = {}
		#p cons
		starts = cons

		cons = values.inject({}){|hash, val| hash[val] = []; hash}
		temp_cons = values.inject({}){|hash, val| hash[val] = []; hash}
		starts.each do |val, arr|
			#p 'arr', arr
			arr.each do |start_con|
			#arr.map{|edges| edges[-1][1].slice(0..1)}.each do |starti, startj|
				starti, startj = start_con[-1][1].slice(0..1)	
				temp_cons[val] = [start_con]
				p 'startj',  starti, startj
				loop do
					starti, startj = trace_contour(val, temp_cons, starti, startj)
					break unless starti and startj
				end
				cons[val].push temp_cons[val][0]
			end
		end
		cons.keys.each{|val| cons[val] = connect_contours(cons[val]);
			cons[val].map!{|con| con.map{|point| point[0]}}}
		
		@last_contours = cons
		gk =  graphkit
		#gk.gp.style = 'data with linespoints'
		gk.data.each{|dk| dk.with = 'lp'}
		gk.gnuplot
		@last_contours
	end
1238685
public void drawCircles( double[][][] houghValues, byte[] circlespixels ) {

        // Copy original input pixels into output
        // circle location display image and
        // combine with saturation at 100
        int roiaddr = 0;
        for( int y = offy; y < offy + height; y++ ) {
            for( int x = offx; x < offx + width; x++ ) {
                // Copy;
                circlespixels[roiaddr] = imageValues[x + offset * y];
                // Saturate
                if (circlespixels[roiaddr] != 0)
                    circlespixels[roiaddr] = 100;
                else
                    circlespixels[roiaddr] = 0;
                roiaddr++;
            }
        }
        // Copy original image to the circlespixels image.
        // Changing pixels values to 100, so that the marked
        // circles appears more clear. Must be improved in
        // the future to show the resuls in a colored image.
        // for(int i = 0; i < width*height ;++i ) {
        // if(imageValues[i] != 0 )
        // if(circlespixels[i] != 0 )
        // circlespixels[i] = 100;
        // else
        // circlespixels[i] = 0;
        // }
        // if (centerPoints == null) {
        // if (useThreshold)
        // getCenterPointsByThreshold(threshold);
        // else
        Coordinate[] centerPoints = getCenterPoints(houghValues, maxCircles);
        // }
        byte cor = -1;
        // Redefine these so refer to ROI coordinates exclusively
        int offset = width;
        int offx = 0;
        int offy = 0;

        for( int l = 0; l < maxCircles; l++ ) {
            int i = (int) centerPoints[l].x;
            int j = (int) centerPoints[l].y;
            // Draw a gray cross marking the center of each circle.
            for( int k = -10; k <= 10; ++k ) {
                int p = (j + k + offy) * offset + (i + offx);
                if (!outOfBounds(j + k + offy, i + offx))
                    circlespixels[(j + k + offy) * offset + (i + offx)] = cor;
                if (!outOfBounds(j + offy, i + k + offx))
                    circlespixels[(j + offy) * offset + (i + k + offx)] = cor;
            }
            for( int k = -2; k <= 2; ++k ) {
                if (!outOfBounds(j - 2 + offy, i + k + offx))
                    circlespixels[(j - 2 + offy) * offset + (i + k + offx)] = cor;
                if (!outOfBounds(j + 2 + offy, i + k + offx))
                    circlespixels[(j + 2 + offy) * offset + (i + k + offx)] = cor;
                if (!outOfBounds(j + k + offy, i - 2 + offx))
                    circlespixels[(j + k + offy) * offset + (i - 2 + offx)] = cor;
                if (!outOfBounds(j + k + offy, i + 2 + offx))
                    circlespixels[(j + k + offy) * offset + (i + 2 + offx)] = cor;
            }
        }
    }
799072
function averageColorNormalized() {
	for (var _len = arguments.length, colors = Array(_len), _key = 0; _key < _len; _key++) {
		colors[_key] = arguments[_key];
	}

	// If a single colors array was provided as opposed to separate arguments
	// for each color, break it out.
	if (colors.length === 1 && Array.isArray(colors[0][0])) colors = colors[0];

	var N = colors.length;

	// Normalize the color components to range [0, 1].
	var normalizedColors = colors.map(function (_ref) {
		var _ref2 = _slicedToArray(_ref, 3),
		    h = _ref2[0],
		    s = _ref2[1],
		    l = _ref2[2];

		return [h / 360, s / 100, l / 100];
	});

	var cartesianAverage = normalizedColors
	// Cylindrical => Cartesian coordinates.
	.map(function (_ref3) {
		var _ref4 = _slicedToArray(_ref3, 3),
		    h = _ref4[0],
		    s = _ref4[1],
		    l = _ref4[2];

		return [s * cos(h * PI2), s * sin(h * PI2), l];
	})
	// Sum the scaled coordinates to find a centerpoint.
	.reduce(function (_ref5, _ref6) {
		var _ref8 = _slicedToArray(_ref5, 3),
		    xA = _ref8[0],
		    yA = _ref8[1],
		    zA = _ref8[2];

		var _ref7 = _slicedToArray(_ref6, 3),
		    x = _ref7[0],
		    y = _ref7[1],
		    z = _ref7[2];

		return [xA + x / N, yA + y / N, zA + z / N];
	}, [0, 0, 0]);

	// Convert the average hue value back to a positive polar angle.
	var H = (atan2(cartesianAverage[Y], cartesianAverage[X]) / PI2 + 1) % 1;

	// Take the arithmetic mean of all saturation values.
	var S = normalizedColors.map(function (_ref9) {
		var _ref10 = _slicedToArray(_ref9, 3),
		    h = _ref10[0],
		    s = _ref10[1],
		    l = _ref10[2];

		return s / N;
	}).reduce(sum);

	// Take the arithmetic mean of all lightness values.
	var L = cartesianAverage[2];

	return [H, S, L];
}
212
def plot_images(images, ax, ims_per_row=5, padding=5, digit_dimensions=(28, 28),
                cmap=matplotlib.cm.binary, vmin=None, vmax=None):
    """"""
    N_images = images.shape[0]
    N_rows = (N_images - 1) // ims_per_row + 1
    pad_value = np.min(images.ravel())
    concat_images = np.full(((digit_dimensions[0] + padding) * N_rows + padding,
                             (digit_dimensions[1] + padding) * ims_per_row + padding), pad_value)
    for i in range(N_images):
        cur_image = np.reshape(images[i, :], digit_dimensions)
        row_ix = i // ims_per_row
        col_ix = i % ims_per_row
        row_start = padding + (padding + digit_dimensions[0]) * row_ix
        col_start = padding + (padding + digit_dimensions[1]) * col_ix
        concat_images[row_start: row_start + digit_dimensions[0],
                      col_start: col_start + digit_dimensions[1]] = cur_image
    cax = ax.matshow(concat_images, cmap=cmap, vmin=vmin, vmax=vmax)
    plt.xticks(np.array([]))
    plt.yticks(np.array([]))
    return cax
431502
def draw_normal(self):
        
        means, scale = self.get_means_and_scales()
        return np.random.normal(means,scale,size=[self.sims,means.shape[0]]).T
685605
def draw(self):
        '''
        
        '''
        observed_arr = self.noise_sampler.generate()
        _ = self.inference(observed_arr)
        feature_arr = self.__convolutional_auto_encoder.extract_feature_points_arr()
        for i in range(len(self.__deconvolution_layer_list)):
            try:
                feature_arr = self.__deconvolution_layer_list[i].forward_propagate(feature_arr)
            except:
                self.__logger.debug("Error raised in Deconvolution layer " + str(i + 1))
                raise

        return feature_arr
231556
def plot_contpix(self, x, y, contpix_x, contpix_y, figname):
        
        fig, axarr = plt.subplots(2, sharex=True)
        plt.xlabel(r"Wavelength $\lambda (\AA)$")
        plt.xlim(min(x), max(x))
        ax = axarr[0]
        ax.step(x, y, where='mid', c='k', linewidth=0.3,
                label=r'$\theta_0$' + "= the leading fit coefficient")
        ax.scatter(contpix_x, contpix_y, s=1, color='r',
                label="continuum pixels")
        ax.legend(loc='lower right', 
                prop={'family':'serif', 'size':'small'})
        ax.set_title("Baseline Spectrum with Continuum Pixels")
        ax.set_ylabel(r'$\theta_0$')
        ax = axarr[1]
        ax.step(x, y, where='mid', c='k', linewidth=0.3,
             label=r'$\theta_0$' + "= the leading fit coefficient")
        ax.scatter(contpix_x, contpix_y, s=1, color='r',
                label="continuum pixels")
        ax.set_title("Baseline Spectrum with Continuum Pixels, Zoomed")
        ax.legend(loc='upper right', prop={'family':'serif', 
            'size':'small'})
        ax.set_ylabel(r'$\theta_0$')
        ax.set_ylim(0.95, 1.05)
        print("Diagnostic plot: fitted 0th order spec w/ cont pix")
        print("Saved as %s.png" % (figname))
        plt.savefig(figname)
        plt.close()
970591
private void drawYValues(Graphics2D chartGraphics) {
    if (!showYAxisValues) {
      return;
    }

    chartGraphics.setColor(axisValuesColour);

    for (int i = 0; i < yValues.length; i++) {
      if (i % yAxisValuesFrequency != 0) {
        continue;
      }

      String yValueStr = yValues[i].toString();

      chartGraphics.setFont(axisValuesFont);
      FontMetrics metrics = chartGraphics.getFontMetrics();

      int valueWidth = metrics.stringWidth(yValueStr);

      if (yValuesHorizontal) {
        // Draw the value with whatever font is now set.
        int valueXPos = margin + yAxisLabelSize.height + (yAxisValuesWidthMax - valueWidth);
        int valueYPos = heatMapTL.y + (i * cellSize.height) + (cellSize.height / 2)
            + (yAxisValuesAscent / 2);

        chartGraphics.drawString(yValueStr, valueXPos, valueYPos);
      }
      else {
        int valueXPos = margin + yAxisLabelSize.height + yAxisValuesAscent;
        int valueYPos = heatMapTL.y + (i * cellSize.height) + (cellSize.height / 2)
            + (valueWidth / 2);

        // Create 270 degree rotated transform.
        AffineTransform transform = chartGraphics.getTransform();
        AffineTransform originalTransform = (AffineTransform) transform.clone();
        transform.rotate(Math.toRadians(270), valueXPos, valueYPos);
        chartGraphics.setTransform(transform);

        // Draw the string.
        chartGraphics.drawString(yValueStr, valueXPos, valueYPos);

        // Revert to original transform before rotation.
        chartGraphics.setTransform(originalTransform);
      }
    }
  }
810221
def _draw_lines_internal(self, coords, colour, bg):
        """"""
        for i, (x, y) in enumerate(coords):
            if i == 0:
                self._screen.move(x, y)
            else:
                self._screen.draw(x, y, colour=colour, bg=bg, thin=True)