image-processing

Edge Detection with Lockbits C#

a 夏天 提交于 2021-01-29 03:48:50
问题 I made a program that implements an edge detection algorithm, but it takes a long time to process. I've read about using lockbits, and unsafe state instead of getpixel and setpixel, but I still don't understand how to use it. This is my example code: private Bitmap SobelEdgeDetect(Bitmap original) { Bitmap b = original; Bitmap bb = original; int width = b.Width; int height = b.Height; int[,] gx = new int[,] { { -1, 0, 1 }, { -2, 0, 2 }, { -1, 0, 1 } }; int[,] gy = new int[,] { { 1, 2, 1 }, {

Remove the annotation box from the picture

被刻印的时光 ゝ 提交于 2021-01-29 00:05:54
问题 ** What I want to do is remove the red box in 5000 images. I wrote a piece of python code for one sample image, but I don't know where got something wrong. I can't realize such purpose. I appreciate any other way to solve this problem.This is the sample image ** ''' import cv2 import numpy as np img = cv2.imread(r'C:\Users\lenvov\Desktop\baowenti\2.jpg') # 缩放 rows, cols, channels = img.shape img = cv2.resize(img, None, fx=0.5, fy=0.5) img_hsv=cv2.cvtColor(img, cv2.COLOR_BGR2HSV) # lower mask

Rotate an image with bicubic interpolation without imrotate

对着背影说爱祢 提交于 2021-01-28 22:02:42
问题 I have implemented a code for image warping using bilinear interpolation: Matlab image rotation I would like to improve the code by using bicubic interpolation to rotate the image WITHOUT using the built-in functions like imrotate or imwarp and interp functions in MATLAB. 回答1: I successfully managed to implement a full working example. Code is based on Anna1994's code: Matlab image rotation Biqubic code is also based on Java (and C++) implementation posted here: http://www.paulinternet.nl/

How to use the 'solidity' property of the regionprops function of MATLAB in Octave?

杀马特。学长 韩版系。学妹 提交于 2021-01-28 21:22:29
问题 I have a code in MATLAB that I have to convert into Octave. I have problems with the following command: boxes = regionprops (L, 'Solidity') where L is a binary image class double. Octave does not know the 'Solidity' property . Is there a similar property or a function that I can use to run the code in Octave? 回答1: According to the definition of 'Solidity' in matlab regionprops this measurement is the Area/ConvexArea. In order to calculate the ConvexArea do the following things: Get id list of

Assigning a 2D image for every face of a 3D cube: MATLAB

泄露秘密 提交于 2021-01-28 20:41:36
问题 I want to build a cube in MATLAB and assign different 2D images for its faces. I think this is called texture mapping. I've searched for such a code, but what I found is a code that is able to assign a single image to all of the cube faces, the code is available here (http://www.mathworks.com/matlabcentral/answers/32070-rgb-images-on-a-3d-cube). Here is the code, cdata = flipdim( imread('peppers.png'), 1 ); cdatar = flipdim( cdata, 2 ); % bottom surface([-1 1; -1 1], [-1 -1; 1 1], [-1 -1; -1

It is taking too much time to process frames while doing pixel by pixel operation of video frames

爱⌒轻易说出口 提交于 2021-01-28 20:13:07
问题 import cv2 import numpy as np cap = cv2.VideoCapture(0) def threshold_slow(image): h = image.shape[0] w = image.shape[1] for x in range(0, w): for y in range(0, h): k = np.array(image[x, y]) print(k) def video(): while True: ret,frame = cap.read() frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) threshold_slow(frame) cv2.imshow('frame',frame) key = cv2.waitKey(25) if key == ord('q'): break if __name__ == '__main__': video() cap.release() cv2.destroyAllWindows() I have done almost everything I

Bitmap Image as a dictionary key

坚强是说给别人听的谎言 提交于 2021-01-28 20:12:53
问题 I want to know what size should be the image to use it as a hashset/dictionary key. I'm also thinking about using hash functions for this purpose but i'm afraid of hash collisions. I need to store about million of images. 回答1: A bitmap image as a key? That's not a very good idea. Hashset keys should be as small as possible, otherwise performance will suffer significantly. What you can do is calculate a hash value (say a SHA1) from the image, and then use that as the key. It's only 20 bytes so

digital image read as an array of integers

杀马特。学长 韩版系。学妹 提交于 2021-01-28 19:52:15
问题 Using Python 's PIL module, we can read an digital image into an array of integers, from PIL import Image from numpy import array img = Image.open('x.jpg') im = array(img) # im is the array representation of x.jpg I wonder how does PIL interpret an image as an array ? First I tried this od -tu1 x.jpg and it indeed gave a sequence of numbers, but how does PIL interpret a color image into a 3D array? In short, my question is that I want to know how can I get a color image's array representation

Preprocessing methods for face recognition in Python

扶醉桌前 提交于 2021-01-28 19:35:35
问题 I am working on a face recognition project where I am recognizing the faces of the person in movement which means the person keeps moving and I have to detect and recognize face. To do this I am using caffemodel for face detection and modified knn approach for face recognition. It works fine but most of the case it gives false recognition. Because the persons are moving, thus its really hard to get a good face image. Below are few examples of the face captured: Camera is placed a bit far from

Fix image orientation in Jimp

…衆ロ難τιáo~ 提交于 2021-01-28 19:30:28
问题 I am using Jimp (https://www.npmjs.com/package/jimp) library to crop the image. Crop is working fine but I only have an issue with image orientation. Sometimes, user uploaded rotated images and its result rotated cropped images. I went through with https://www.npmjs.com/package/jimp documentation but couldn't find anything related to this. Here are couple of links I went through but didn't helped: https://justmarkup.com/articles/2019-10-21-image-orientation/ Accessing JPEG EXIF rotation data