image-rotation

Detect if a text image is upside down

二次信任 提交于 2019-12-03 01:04:03
I have some hundreds of images (scanned documents), most of them are skewed. I wanted to de-skew them using Python. Here is the code I used: import numpy as np import cv2 from skimage.transform import radon filename = 'path_to_filename' # Load file, converting to grayscale img = cv2.imread(filename) I = cv2.cvtColor(img, COLOR_BGR2GRAY) h, w = I.shape # If the resolution is high, resize the image to reduce processing time. if (w > 640): I = cv2.resize(I, (640, int((h / w) * 640))) I = I - np.mean(I) # Demean; make the brightness extend above and below zero # Do the radon transform sinogram =

Rotate an Imagewith Animation

≡放荡痞女 提交于 2019-12-02 19:14:22
What I Have I have an arrow image (like the left one). When the user clicks on it, it should rotate 180 degree with an animation and should look like the right one. What I Have Done private void rotate(float degree, final int toggleV) { final RotateAnimation rotateAnim = new RotateAnimation(0.0f, degree, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); rotateAnim.setDuration(500); toggle.startAnimation(rotateAnim); rotateAnim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public

Change direction of javafx RotateTransition to direction of clockwise

时间秒杀一切 提交于 2019-12-02 18:17:18
问题 in my javafx application, i have an imageView for which I have created an Rotate trasition, everything works fine , but the rotation direction is in counterclockwise of watch, i want to make it in opposite direction . this is My code : RotateTransition rt = new RotateTransition(Duration.millis(3000), myImageView); rt.setByAngle(360); rt.setCycleCount(1); rt.setAutoReverse(false); rt.play() ; 回答1: It seems to be undocumented, but setting a negative angle results in a counter-clockwise rotation

Cropping a cross rectangle from image using c#

喜夏-厌秋 提交于 2019-12-02 09:25:00
问题 What I want to do is basically cropping a rectangle from an image. However, it should satisfy some special cases: I want to crop an angled rectangle on image. I don't want to rotate the image and crop a rectangle :) If cropping exceeds the image size, I don't want to crop an empty background color. I want to crop from back of the starting point, that will end at starting point when rectangle size completed. I know I couldn't explain well so if I show what I want visually: The blue dot is the

Rotating speedometer needle gauge around its center as the speed changes

*爱你&永不变心* 提交于 2019-12-02 09:22:05
Hi all, I have written an application where I have a speedometer with a needle vertically set at 90 degree and I am trying to rotate the needle around its center with the speed that changes for every one second(I am displaying the speed in a text view that changes randomly from 0 to 120) I am getting the speed from a remote service and displaying in a textview. so as the speed changes the speedometer needle gauge should change accordingly around its center. I mean If speed is 30 the needle should be at 30 and so on in speedometer. My code is not working exactly, How to get around this problem?

How to straighten a tilted square shape in an image?

我只是一个虾纸丫 提交于 2019-12-02 06:17:39
How can I straighten a tilted square shape in an image? I do not know the angle with which it is tilted and the code must calculate it and then rotate it automatically. For example, I have the following image: which should be rotated to give the following output image: A simple way using only the top and bottom corners. Note that this approach relies on the upper and lower most corners: i = imread('sq.jpg'); i_bw = im2bw(i)==0; % Modify the strel as required se = strel('square', 10); i_ed = imopen(i_bw, se); limits = sum(i_ed, 2); top_y = find(limits>0, 1); bottom_y = find(limits>0, 1, 'last')

AffineTransform truncates image

眉间皱痕 提交于 2019-12-01 14:18:34
I have an image and I have to rotate it by 45, 90, 135, 180 degrees. What I am doing: try { BufferedImage src = ImageIO.read(new File("src.png")); double ang = Math.toRadians(90); AffineTransform t = new AffineTransform(); t.setToRotation(ang, src.getWidth() / 2, src.getHeight() / 2); AffineTransformOp op = new AffineTransformOp(t, null); BufferedImage dst = new BufferedImage(src.getWidth(), src.getHeight(), src.getType()); op.filter(src, dst); ImageIO.write(dst, "png", new File("output.png")); } catch(Exception ex) { ex.printStackTrace(); } The problem is that image changes its position and

Java rotate image turns part of background black

江枫思渺然 提交于 2019-12-01 14:13:47
When I try to rotate an image it appears that a part of the background turns black (my images are transparents) Background white Part of background turns black Here's the code that rotate the image : public BufferedImage rotate(int height, int width, BufferedImage originalImg, int angle) { BufferedImage rotateImage = null; try { rotateImage = new BufferedImage(height, width, BufferedImage.TYPE_INT_RGB); AffineTransform a90 = AffineTransform.getRotateInstance(Math.toRadians(angle), height / 2, width / 2); AffineTransformOp op90 = new AffineTransformOp(a90, AffineTransformOp.TYPE_BILINEAR); op90

Java rotate image turns part of background black

坚强是说给别人听的谎言 提交于 2019-12-01 12:21:58
问题 When I try to rotate an image it appears that a part of the background turns black (my images are transparents) Background white Part of background turns black Here's the code that rotate the image : public BufferedImage rotate(int height, int width, BufferedImage originalImg, int angle) { BufferedImage rotateImage = null; try { rotateImage = new BufferedImage(height, width, BufferedImage.TYPE_INT_RGB); AffineTransform a90 = AffineTransform.getRotateInstance(Math.toRadians(angle), height / 2,

Rotating an image around a specified point doesn't work! (Android)

淺唱寂寞╮ 提交于 2019-12-01 11:40:01
I'm rotating an ImageView with postRotate(float degrees, float px, float py), setting px and py to a few differnt values including (0,0) and (imgView.getHeight(),imgView.getWidth()) but it refuses to rotate around any other point than the center. I'm wondering whether it's got anything to do with the fact that my gravity is center in the LinearLayout? My layout: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center"> <ImageView android:id="@+id