Matlab - DoubleFlip Image
1 2 function flipIMG=DoubleFlip(img) 3 4 tic 5 6 flipIMG = img([1:end/2, end/2:-1:1], [1:end/2, end/2:-1:1], :); 7 8 toc
12730 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
1 2 function flipIMG=DoubleFlip(img) 3 4 tic 5 6 flipIMG = img([1:end/2, end/2:-1:1], [1:end/2, end/2:-1:1], :); 7 8 toc
1 2 import java.awt.Rectangle; 3 import java.awt.Robot; 4 import java.awt.Toolkit; 5 import java.awt.image.BufferedImage; 6 import java.io.File; 7 8 import javax.imageio.ImageIO; 9 10 public class screen2image 11 { 12 public static void main(String[] args) throws Exception 13 { 14 Robot robot = new Robot(); 15 16 BufferedImage screenShot = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())); 17 ImageIO.write(screenShot, "JPG", new File("screenShot.jpg")); 18 } 19 }
1 2 public BufferedImage Embrossing(BufferedImage bi) 3 { 4 BufferedImage buff = new BufferedImage(bi.getWidth(), bi.getHeight(), bi.getType()); 5 6 Kernel kernel = new Kernel(3, 3, new float[] { 7 -2f, 0f, 0f, 8 0f, 1f, 0f, 9 0f, 0f, 2f 10 }); 11 12 ConvolveOp op = new ConvolveOp(kernel); 13 op.filter(bi, buff); 14 15 return buff; 16 }
1 2 public BufferedImage Blurring(BufferedImage bi) 3 { 4 BufferedImage buff = new BufferedImage(bi.getWidth(), bi.getHeight(), bi.getType()); 5 6 Kernel kernel = new Kernel(3, 3, new float[] { 7 1f/9f, 1f/9f, 1f/9f, 8 1f/9f, 1f/9f, 1f/9f, 9 1f/9f, 1f/9f, 1f/9f 10 }); 11 12 ConvolveOp op = new ConvolveOp(kernel); 13 op.filter(bi, buff); 14 15 return buff; 16 }
1 2 public BufferedImage Sharpening(BufferedImage bi) 3 { 4 BufferedImage buff = new BufferedImage(bi.getWidth(), bi.getHeight(), bi.getType()); 5 6 Kernel kernel = new Kernel(3, 3, new float[] { 7 -1f, -1f, -1f, 8 -1f, 9f, -1f, 9 -1f, -1f, -1f 10 }); 11 12 ConvolveOp op = new ConvolveOp(kernel); 13 op.filter(bi, buff); 14 15 return buff; 16 }
1 2 public BufferedImage toGray(BufferedImage bi) 3 { 4 ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY); 5 ColorConvertOp op = new ColorConvertOp(cs, null); 6 7 return op.filter(bi, null); 8 }
1 2 public BufferedImage rotate90DX(BufferedImage bi) 3 { 4 int width = bi.getWidth(); 5 int height = bi.getHeight(); 6 7 BufferedImage biFlip = new BufferedImage(height, width, bi.getType()); 8 9 for(int i=0; i<width; i++) 10 for(int j=0; j<height; j++) 11 biFlip.setRGB(height-1-j, width-1-i, bi.getRGB(i, j)); 12 13 return biFlip; 14 }
1 2 public BufferedImage rotate90SX(BufferedImage bi) 3 { 4 int width = bi.getWidth(); 5 int height = bi.getHeight(); 6 7 BufferedImage biFlip = new BufferedImage(height, width, bi.getType()); 8 9 for(int i=0; i<width; i++) 10 for(int j=0; j<height; j++) 11 biFlip.setRGB(j, i, bi.getRGB(i, j)); 12 13 return biFlip; 14 }
1 2 public BufferedImage halfFlipW(BufferedImage bi) 3 { 4 int width = bi.getWidth(); 5 int height = bi.getHeight(); 6 7 BufferedImage biFlip = new BufferedImage(width, height, bi.getType()); 8 9 for(int i=0; i<width; i++) 10 for(int j=0; j<height/2; j++) 11 { 12 biFlip.setRGB(i, j, bi.getRGB(i, j)); 13 biFlip.setRGB(i, (height-1)-j, bi.getRGB(i, j)); 14 } 15 16 return biFlip; 17 }
1 2 public BufferedImage halfFlipH(BufferedImage bi) 3 { 4 int width = bi.getWidth(); 5 int height = bi.getHeight(); 6 7 BufferedImage biFlip = new BufferedImage(width, height, bi.getType()); 8 9 for(int i=0; i<width/2; i++) 10 for(int j=0; j<height; j++) 11 { 12 biFlip.setRGB(i, j, bi.getRGB(i, j)); 13 biFlip.setRGB((width-1)-i, j, bi.getRGB(i, j)); 14 } 15 16 return biFlip; 17 }
1 2 public BufferedImage flipH(BufferedImage bi) 3 { 4 int width = bi.getWidth(); 5 int height = bi.getHeight(); 6 7 BufferedImage biFlip = new BufferedImage(width, height, bi.getType()); 8 9 for(int i=0; i<width; i++) 10 for(int j=0; j<height; j++) 11 biFlip.setRGB((width-1)-i, j, bi.getRGB(i, j)); 12 13 return biFlip; 14 }
1 2 public BufferedImage flipW(BufferedImage bi) 3 { 4 int width = bi.getWidth(); 5 int height = bi.getHeight(); 6 7 BufferedImage biFlip = new BufferedImage(width, height, bi.getType()); 8 9 for(int i=0; i<width; i++) 10 for(int j=0; j<height; j++) 11 biFlip.setRGB(i, (height-1)-j, bi.getRGB(i, j)); 12 13 return biFlip; 14 }
1 2 public BufferedImage zoomOut(BufferedImage bi, int scale) 3 { 4 int width = bi.getWidth() / scale; 5 int height = bi.getHeight() / scale; 6 7 BufferedImage biScale = new BufferedImage(width, height, bi.getType()); 8 9 for(int i=0; i<width; i++) 10 for(int j=0; j<height; j++) 11 biScale.setRGB(i, j, bi.getRGB(i*scale, j*scale)); 12 13 return biScale; 14 }
1 2 public BufferedImage zoomIn(BufferedImage bi, int scale) 3 { 4 int width = scale * bi.getWidth(); 5 int height = scale * bi.getHeight(); 6 7 BufferedImage biScale = new BufferedImage(width, height, bi.getType()); 8 9 // Cicla dando un valore medio al pixel corrispondente 10 for(int i=0; i<width; i++) 11 for(int j=0; j<height; j++) 12 biScale.setRGB(i, j, bi.getRGB(i/scale, j/scale)); 13 14 return biScale; 15 }
1 2 /* 3 resizer.jsx for Adobe Photoshop CS2 4 5 WARNING: this script changes documents that will be processed. 6 so be sure to duplicate documents before script runs. 7 8 this script resizes images storing in given number of pixel. 9 smaller images than given number won't be resized. 10 all images will be changed into RGB color mode. 11 12 last update: 2006-10-26 13 */ 14 15 preferences.rulerUnits = Units.PIXELS; 16 17 cutVal = 960; 18 fileType = "*.psd"; 19 20 folderObj = Folder.selectDialog("select folder"); 21 22 if(folderObj != null) { 23 inputFileType = prompt("input file type like '*.psd'", fileType); 24 if(inputFileType != null) { fileType = inputFileType; } 25 26 inputCutVal = prompt("input length (pixel)", cutVal); 27 if(inputCutVal != null) { cutVal = eval(inputCutVal); } 28 29 fileList = folderObj.getFiles(fileType); 30 31 for(i = 0; i < fileList.length; i++) { 32 open(fileList[i]); 33 34 if(activeDocument.width.value > cutVal || activeDocument.height.value > cutVal) { 35 if(activeDocument.width.value > activeDocument.height.value) { 36 activeDocument.resizeImage( 37 cutVal, 38 (cutVal / activeDocument.width.value) * activeDocument.height.value, 39 72, 40 ResampleMethod.BICUBICSHARPER 41 ); 42 } else { 43 activeDocument.resizeImage( 44 (cutVal / activeDocument.height.value) * activeDocument.width.value, 45 cutVal, 46 72, 47 ResampleMethod.BICUBICSHARPER 48 ); 49 } 50 } 51 52 activeDocument.changeMode(ChangeMode.RGB); 53 54 activeDocument.close(SaveOptions.SAVECHANGES); 55 } 56 }