crop

Delphi - how do I crop a bitmap “in place”?

随声附和 提交于 2019-11-28 13:29:11
If I have a TBitmap and I want to obtain a cropped image from this bitmap, can I perform the cropping operation "in place"? e.g. if I have a bitmap that is 800x600, how can I reduce (crop) it so that it contains the 600x400 image at the centre, i.e. the resulting TBitmap is 600x400, and consists of the rectangle bounded by (100, 100) and (700, 500) in the original image? Do I need to go via another bitmap or can this operation be done within the original bitmap? You can use the BitBlt function try this code. procedure CropBitmap(InBitmap, OutBitMap : TBitmap; X, Y, W, H :Integer); begin

swift: how to delete part of audio?

南笙酒味 提交于 2019-11-28 13:02:52
I'm creating a simple audio editing tool to trim and delete from an audio. I implemented the trim function and it is working fine. However I searched and tried to implement the delete function and here is my code: func deleteExportAsset(_ asset: AVAsset, fileName: String, completeAudioTime: CGFloat) -> URL { print("\(#function)") let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] let trimmedSoundFileURL = documentsDirectory.appendingPathComponent(fileName) print("saving to \(trimmedSoundFileURL.absoluteString)") if FileManager.default.fileExists

Crop image by polygon area in Java

浪子不回头ぞ 提交于 2019-11-28 13:01:11
by using Canvas and JS I can draw a shape like this and have the x,y of each point : Tha area can be choosen by more than 4 points, look at this link to have an idea. I need to save and crop the image of the selected area by using the points. I can not use BufferedImage as it is just rectangular. Which lib in java I can use? MadProgrammer Okay, so starting with... I used... BufferedImage source = ImageIO.read(new File("Example.jpg")); GeneralPath clip = new GeneralPath(); clip.moveTo(65, 123); clip.lineTo(241, 178); clip.lineTo(268, 405); clip.lineTo(145, 512); clip.closePath(); Rectangle

jQuery Guillotine - Swap Image

喜夏-厌秋 提交于 2019-11-28 11:33:52
问题 I am using jquery guillotine to crop image and save to the server but unfortunately when i want to do things dynamically it doesn't work as it should be . I have created thumbnails on the same picture and when you click on a thumbnail it should let you edit that picture and crop etc. I have 3 scripts on the page , 1 ) guillotine , 2) scripts that when you click on thumbnails swaps the small image with the big one , 3) and when you click on crop button gets the values and does the job in php.

MATLAB: how do I crop out a circle from an image

人走茶凉 提交于 2019-11-28 11:17:42
I need to crop a circle in MATLAB. I need to perform iris segmentation, and I´ve identified the center point and the radius of the iris, and I need to cut it off from the image. I have a vector ci that ci(1) is X-coordinate ci(2) is Y-coordinate and ci(3) is the radius of the circle. One way to do this is to create a binary mask with ones inside the circle and zeros outside. You can then use this array to either mask everything outside the circle with NaNs, or to read the pixel values of the image inside the mask. To create a circle mask, an easy way is to create coordinate arrays centered on

How to crop huge image

人走茶凉 提交于 2019-11-28 10:20:41
I need to process large images (20,000x20,000pixels) in C#. Opening these images directly isn't the way to go because of memory limitations, but what I want to do is split the image into smaller pieces (cropping). I was looking for a 3rd party library that could the trick, but so far no result. I tried FreeImage and ImageMagick, but they cannot open an 20,000x20x000 pixel image. How can I achieve this? My current project at work consists of an image viewer/analyzing program capable of loading images in excess of 16 gb. You have to use manual file IO, pull the header information out and create

How to crop a numpy 2d array to non-zero values?

ぐ巨炮叔叔 提交于 2019-11-28 09:28:02
问题 Let's say i have a 2d boolean numpy array like this: import numpy as np a = np.array([ [0,0,0,0,0,0], [0,1,0,1,0,0], [0,1,1,0,0,0], [0,0,0,0,0,0], ], dtype=bool) How can i in general crop it to the smallest box (rectangle, kernel) that includes all True values? So in the example above: b = np.array([ [1,0,1], [1,1,0], ], dtype=bool) 回答1: After some more fiddling with this, i actually found a solution myself: coords = np.argwhere(a) x_min, y_min = coords.min(axis=0) x_max, y_max = coords.max

Crop saved Image using com.android.camera.action.CROP on android

橙三吉。 提交于 2019-11-28 09:07:45
问题 I have reads many question about this, but I still failed using this code... maybe anyone can corect my code... I want to crop an image from file that i know the location using com.android.camera.action.CROP like this... mImageCaptureUri = Uri.fromFile(f); Intent intent = new Intent("com.android.camera.action.CROP"); intent.setType("image/*"); intent.setData(mImageCaptureUri); intent.putExtra("crop", true); intent.putExtra("outputX", 200); intent.putExtra("outputY", 200); intent.putExtra(

crop center portion of a numpy image

ぃ、小莉子 提交于 2019-11-28 09:02:28
Let's say I have a numpy image of some width x and height y. I have to crop the center portion of the image to width cropx and height cropy. Let's assume that cropx and cropy are positive non zero integers and less than the respective image size. What's the best way to apply the slicing for the output image? Something along these lines - def crop_center(img,cropx,cropy): y,x = img.shape startx = x//2-(cropx//2) starty = y//2-(cropy//2) return img[starty:starty+cropy,startx:startx+cropx] Sample run - In [45]: img Out[45]: array([[88, 93, 42, 25, 36, 14, 59, 46, 77, 13, 52, 58], [43, 47, 40, 48,

iPhone - How do you make a resizable rectangle for cropping images?

陌路散爱 提交于 2019-11-28 07:51:59
I'm having a trouble making a re-sizable rectangle for cropping my images. I'm trying to achieve something like this picture: http://img192.imageshack.us/img192/8930/customcropbox.jpg Well, the only problem is I have no clue where to actually start. I need some advice to how I can achieve this effect of cropping. What documentation should I read up on? Core Graphics or Quartz 2d? Both? I've been coding for the iPhone since it's release date but I've never actually used core graphics and etc. Any help or advice would be much appreciated. I'll throw my code up here as I progress to show how it's