Posts

Showing posts with the label image

Saving a Numpy array as an image

Image
Saving a Numpy array as an image I have a matrix in the type of a Numpy array. How would I write it to disk it as an image? Any format works (png, jpeg, bmp...). One important constraint is that PIL is not present. I'd just like to note that some of the answers below, and surely some of the people coming and finding this question, do not meet the constraint listed above of being without PIL. Since some askers and some answers both avoid that constraint, I encourage anyone who's here and doesn't mind having PIL to look below, and any non-PIL answers (new or old) to mention that they're a PIL-is-used type of answer, to distinguish themselves from answers meeting the original constraint. – lindes Oct 30 '13 at 15:46 14 Answers 14 Yo...

how to run textcleaner imagemagick script from git bash

how to run textcleaner imagemagick script from git bash I installed Git Bash on Windows system. Now I want to run textcleaner Imagemagick script from it. Which package do I need to download to run textcleaner script and how to set the path for that script. Please help. found this fancy old comment: stackoverflow.com/questions/33411898/…, This should help :) – Diana Jul 2 at 7:10 this is not working. – ankit jain Jul 2 at 7:12 what did you try? And is ur textcleaner in the right directory? – Diana Jul 2 at 7:34 and if you ...

Export to excel using Laravel Excel 3.0

Export to excel using Laravel Excel 3.0 How to export to excel with Maatwebsite/Laravel-Excel version 3.0 within the image? Maatwebsite/Laravel-Excel I do the export with Exports Class, I need to export with the image, this is the code all I got. https://paste.laravel.io/34e11e43-73c4-42c6-adcc-0206946a8fc8 By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Black flashing around drawn image

Black flashing around drawn image I'm currently trying to draw an image to a JFrame (just a nonsense test image). In the code bite below, the image is drawn to the JFrame, but the area around the image that doesn't fill JFrame is black that rapidly flashes. Here is the code below: try { myImage = ImageIO.read(ImagesMain.class.getResource("/Textures/TestImage.png")); }catch(Exception e) { e.printStackTrace(); } BufferStrategy strategy = null; while(strategy == null) {//I know this is terrible practice, just doing this way because its inside main strategy = myCanvas.getBufferStrategy(); if(myCanvas.getBufferStrategy() == null) { myCanvas.createBufferStrategy(3); } } myFrame.setVisible(true); //Rendering part while(true) { do { do { g = strategy.getDrawGraphics(); g.setColor(Color.WHITE); g.drawImage(myImage, 20, 20, null...

Images not displaying the first time in this object program in JS

Images not displaying the first time in this object program in JS I am making a battleship game with polar coordinates. After the user chooses two points, a battleship should be drawn in the middle. My Battleship constructor looks like this: function Battleship(size, location, source){ this.size = size; //initializing the image this.image = new Image(); this.image.src = source; this.getMiddlePoint = function(){ //get midpoint of ship ... } this.distanceBetween = function(t1, t2){ //dist between two points } this.display = function(){ var point = [this.radius]; point.push(this.getMiddlePoint()); point = polarToReal(point[0], point[1] * Math.PI / 12); //now point has canvas coordinates of midpoint var width = this.distanceBetween(this.info[0][0], this.info[this.info.length-1][0]); var ratio = this.image.width / width; ...

resolution of the original image from JPEG compression

resolution of the original image from JPEG compression JPEG compression of two images yields two 1MB and 2MB files. From these compressed files can we have an idea about the resolutions of the original images? How is that possible? thanks 1 Answer 1 The resolution of the image is the same before and after JPEG compression. JPEG compression may change the resolution of one or more components with respect to another component (usually Y). At least one component has to be sampled at the original rate so the image resolution does not change. A 50% difference in compression can result from the selection of quantization tables or (more likely) subsampling of components. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject ...

rectangle, Contour detection with python3, opencv3

Image
rectangle, Contour detection with python3, opencv3 I want to detect paper sheet from image. i applied medianBlur, Canny , dilate, threshold, etc. algorithms to find.i am able to find sheet but don't know how to crop rectangle and apply transformation answer sheet This my code import numpy as np import cv2 image = cv2.imread('im_1.jpg') image = cv2.resize(image, (800, 600)) draw = np.zeros_like(image) gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) ret, thresh = cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY) kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (3, 3)) thresh = cv2.erode(thresh, kernel, iterations=4) thresh = cv2.dilate(thresh, kernel, iterations=4) im, cnts, hier = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) max_area = -1 max_c = 0 for i in range(len(cnts)): contour = cnts[i] area = cv2.contourArea(contour) if (area > max_area): max_area = area max_c = i contour = cnts[max_c] rect = cv2.minAreaRect(contour) ...

Issues in order to adapt label_image.py

Issues in order to adapt label_image.py I'd like to modify label_image.py, my main goal is to create a GUI. Some words about my ideas I'm trying to modify some stuffs in the code (https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/label_image/label_image.py), but it doesn't work. I first tried to had a filename = askopenfilename() line, which it seems to work. filename = askopenfilename() Then I don't know how I can adapt the code. For example, in order to load MY graph, which line have I to adapt? Maybe line 26 : def load_graph(model_file) : and putting def load_graph("c:my_path_hereowngraph.pb): ? It doesn't work either. def load_graph(model_file) : def load_graph("c:my_path_hereowngraph.pb): I have the same question for label, and also for the choosen picture: filename = askopenfilename() --> where can I load MY picture (I tried to replace all file_name by filename but it fails). filename = askopenfilename() file_name filen...