├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md └── marvinj ├── images └── lena.jpg ├── release ├── builder.jar ├── marvinj-0.7.js ├── marvinj-0.8.js ├── marvinj-0.9.js └── marvinj-1.0.js ├── src ├── MarvinColor.js ├── MarvinFramework.js ├── MarvinJSUtils.js ├── color │ └── MarvinColorModelConverter.js ├── image │ ├── MarvinImage.js │ ├── MarvinImageMask.js │ └── MarvinSegment.js ├── math │ └── MarvinMath.js ├── plugins │ ├── MarvinAbstractImagePlugin.js │ ├── background │ │ ├── DetermineFixedCameraBackground.js │ │ └── DetermineSceneBackground.js │ ├── blur │ │ └── GaussianBlur.js │ ├── color │ │ ├── AlphaBoundary.js │ │ ├── AverageColor.js │ │ ├── BlackAndWhite.js │ │ ├── BrightnessAndContrast.js │ │ ├── ColorChannel.js │ │ ├── Emboss.js │ │ ├── GrayScale.js │ │ ├── Invert.js │ │ ├── Sepia.js │ │ ├── Thresholding.js │ │ └── ThresholdingNeighborhood.js │ ├── combine │ │ ├── CombineByAlpha.js │ │ └── MergePhotos.js │ ├── convolution │ │ └── Convolution.js │ ├── corner │ │ └── Moravec.js │ ├── edge │ │ └── Prewitt.js │ ├── fill │ │ └── BoundaryFill.js │ ├── halftone │ │ └── ErrorDiffusion.js │ ├── morphological │ │ ├── Closing.js │ │ ├── Dilation.js │ │ └── Erosion.js │ ├── pattern │ │ └── FindTextRegions.js │ ├── render │ │ └── IteratedFunctionSystem.js │ ├── segmentation │ │ ├── Crop.js │ │ └── FloodfillSegmentation.js │ └── transform │ │ └── Scale.js └── util │ ├── MarvinAttributes.js │ └── MarvinPoint.js └── tools └── builder ├── .metadata ├── .lock ├── .mylyn │ ├── .tasks.xml.zip │ ├── repositories.xml.zip │ └── tasks.xml.zip ├── .plugins │ ├── org.eclipse.core.resources │ │ ├── .projects │ │ │ └── Builder │ │ │ │ ├── .markers │ │ │ │ └── org.eclipse.jdt.core │ │ │ │ └── state.dat │ │ ├── .root │ │ │ ├── .indexes │ │ │ │ ├── history.version │ │ │ │ ├── properties.index │ │ │ │ └── properties.version │ │ │ └── 5.tree │ │ └── .safetable │ │ │ └── org.eclipse.core.resources │ ├── org.eclipse.core.runtime │ │ └── .settings │ │ │ ├── com.collabnet.subversion.merge.prefs │ │ │ ├── org.eclipse.core.resources.prefs │ │ │ ├── org.eclipse.debug.ui.prefs │ │ │ ├── org.eclipse.jdt.core.prefs │ │ │ ├── org.eclipse.jdt.launching.prefs │ │ │ ├── org.eclipse.jdt.ui.prefs │ │ │ ├── org.eclipse.m2e.discovery.prefs │ │ │ ├── org.eclipse.mylyn.context.core.prefs │ │ │ ├── org.eclipse.mylyn.monitor.ui.prefs │ │ │ ├── org.eclipse.team.ui.prefs │ │ │ ├── org.eclipse.ui.editors.prefs │ │ │ ├── org.eclipse.ui.ide.prefs │ │ │ ├── org.eclipse.ui.prefs │ │ │ ├── org.eclipse.ui.workbench.prefs │ │ │ ├── org.tigris.subversion.subclipse.tools.usage.prefs │ │ │ └── org.tigris.subversion.subclipse.ui.prefs │ ├── org.eclipse.debug.core │ │ └── .launches │ │ │ └── Builder.launch │ ├── org.eclipse.debug.ui │ │ ├── dialog_settings.xml │ │ └── launchConfigurationHistory.xml │ ├── org.eclipse.jdt.core │ │ ├── 1075156909.index │ │ ├── 1144188029.index │ │ ├── 1820024274.index │ │ ├── 1825553220.index │ │ ├── 2706502329.index │ │ ├── 2708239607.index │ │ ├── 3015671029.index │ │ ├── 3256372620.index │ │ ├── 3521617142.index │ │ ├── 3626931047.index │ │ ├── 3814551627.index │ │ ├── 384216248.index │ │ ├── 4018706093.index │ │ ├── 4149142647.index │ │ ├── 683184654.index │ │ ├── 728132027.index │ │ ├── 739078005.index │ │ ├── externalLibsTimeStamps │ │ ├── invalidArchivesCache │ │ ├── javaLikeNames.txt │ │ ├── nonChainingJarsCache │ │ ├── savedIndexNames.txt │ │ └── variablesAndContainers.dat │ ├── org.eclipse.jdt.launching │ │ ├── .install.xml │ │ └── libraryInfos.xml │ ├── org.eclipse.jdt.ui │ │ ├── OpenTypeHistory.xml │ │ ├── QualifiedTypeNameHistory.xml │ │ └── dialog_settings.xml │ ├── org.eclipse.m2e.logback.configuration │ │ └── logback.1.4.0.20130601-0317.xml │ ├── org.eclipse.ui.workbench │ │ ├── dialog_settings.xml │ │ ├── workbench.xml │ │ └── workingsets.xml │ └── org.tigris.subversion.subclipse.ui │ │ └── dialog_settings.xml └── version.ini └── Builder ├── .classpath ├── .project ├── .settings └── org.eclipse.jdt.core.prefs ├── lib └── commons-io-2.4.jar └── src └── Builder.java /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear on external disk 35 | .Spotlight-V100 36 | .Trashes 37 | 38 | # Directories potentially created on remote AFP share 39 | .AppleDB 40 | .AppleDesktop 41 | Network Trash Folder 42 | Temporary Items 43 | .apdisk 44 | 45 | # ========================= 46 | # ECLIPSE CONF AND BINARIES 47 | # ========================= 48 | 49 | marvinproject/dev/.metadata/ 50 | *.class 51 | *.html 52 | *.log 53 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MarvinJ 2 | MarvinJ was created to be the Javascript version of Marvin Image Processing Framework aiming to provide the same features in the web, server and mobile platforms powered by Javascript. 3 | 4 | If you are not familiar with Marvin Framework and want to play with MarvinJ, don't worry. The rest of this article shows the basic image processing features of MarvinJ using JSFiddle snippets that you can make your own version and play with it. 5 | 6 | ### Image Loading 7 | In the case of MarvinJ we load images from URLs and usually use a HTML5 canvas for displaying processed images. 8 | 9 | ``` 10 | var canvas = document.getElementById("canvas"); 11 | var image = new MarvinImage(); 12 | 13 | image.load("https://i.imgur.com/4O8VFQY.jpg", function(){ 14 | image.draw(canvas); 15 | }); 16 | ``` 17 | Continue Reading: 18 | 19 | ### "Playing with image processing in Javascript using MarvinJ 1.0 (JSFiddle Examples)" 20 | http://marvinj.org/en/releases/marvinj_1.0.html 21 | 22 | -------------------------------------------------------------------------------- /marvinj/images/lena.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/images/lena.jpg -------------------------------------------------------------------------------- /marvinj/release/builder.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/release/builder.jar -------------------------------------------------------------------------------- /marvinj/release/marvinj-0.7.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/release/marvinj-0.7.js -------------------------------------------------------------------------------- /marvinj/release/marvinj-0.8.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/release/marvinj-0.8.js -------------------------------------------------------------------------------- /marvinj/release/marvinj-0.9.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/release/marvinj-0.9.js -------------------------------------------------------------------------------- /marvinj/release/marvinj-1.0.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/release/marvinj-1.0.js -------------------------------------------------------------------------------- /marvinj/src/MarvinColor.js: -------------------------------------------------------------------------------- 1 | 2 | function MarvinColor(red, green, blue){ 3 | this.red = red; 4 | this.green = green; 5 | this.blue = blue; 6 | return this; 7 | } 8 | 9 | MarvinColor.prototype.setId = function(id){ 10 | this.id = id; 11 | }; 12 | 13 | MarvinColor.prototype.getId = function(){ 14 | return this.id; 15 | }; 16 | 17 | MarvinColor.prototype.setName = function(name){ 18 | this.name = name; 19 | }; 20 | 21 | MarvinColor.prototype.getName = function(){ 22 | return this.name; 23 | }; -------------------------------------------------------------------------------- /marvinj/src/MarvinFramework.js: -------------------------------------------------------------------------------- 1 | var marvinLoadPluginMethods = function(callback){ 2 | Marvin.plugins = new Object(); 3 | 4 | // Alpha Boundary 5 | Marvin.plugins.alphaBoundary = new AlphaBoundary(); 6 | Marvin.alphaBoundary = function(imageIn, imageOut, radius){ 7 | Marvin.plugins.alphaBoundary.setAttribute("radius", radius) 8 | Marvin.plugins.alphaBoundary.process(imageIn, imageOut, null, MarvinImageMask.NULL_MASK, false); 9 | }; 10 | 11 | // Average Color 12 | Marvin.plugins.averageColor = new AverageColor(); 13 | Marvin.averageColor = function(imageIn){ 14 | var attrOut = new MarvinAttributes(); 15 | Marvin.plugins.averageColor.process(imageIn, null, attrOut, MarvinImageMask.NULL_MASK, false); 16 | return attrOut.get("averageColor"); 17 | }; 18 | 19 | // Black And White 20 | Marvin.plugins.blackAndWhite = new BlackAndWhite(); 21 | Marvin.blackAndWhite = function(imageIn, imageOut, level){ 22 | Marvin.plugins.blackAndWhite.setAttribute("level", level); 23 | Marvin.plugins.blackAndWhite.process(imageIn, imageOut, null, MarvinImageMask.NULL_MASK, false); 24 | }; 25 | 26 | // BoundaryFill 27 | Marvin.plugins.boundaryFill = new BoundaryFill(); 28 | Marvin.boundaryFill = function(imageIn, imageOut, x, y, color, threshold){ 29 | Marvin.plugins.boundaryFill.setAttribute("x", x); 30 | Marvin.plugins.boundaryFill.setAttribute("y", y); 31 | Marvin.plugins.boundaryFill.setAttribute("color", color); 32 | if(threshold != null){ Marvin.plugins.boundaryFill.setAttribute("threshold", threshold); } 33 | 34 | Marvin.plugins.boundaryFill.process(imageIn, imageOut, null, MarvinImageMask.NULL_MASK, false); 35 | }; 36 | 37 | // Brightness and Contrast 38 | Marvin.plugins.brightnessAndContrast = new BrightnessAndContrast(); 39 | Marvin.brightnessAndContrast = function(imageIn, imageOut, brightness, contrast){ 40 | Marvin.plugins.brightnessAndContrast.setAttribute("brightness", brightness); 41 | Marvin.plugins.brightnessAndContrast.setAttribute("contrast", contrast); 42 | Marvin.plugins.brightnessAndContrast.process(imageIn, imageOut, null, MarvinImageMask.NULL_MASK, false); 43 | }; 44 | 45 | // Color Channel 46 | Marvin.plugins.colorChannel = new ColorChannel(); 47 | Marvin.colorChannel = function(imageIn, imageOut, red, green, blue){ 48 | Marvin.plugins.colorChannel.setAttribute("red", red); 49 | Marvin.plugins.colorChannel.setAttribute("green", green); 50 | Marvin.plugins.colorChannel.setAttribute("blue", blue); 51 | Marvin.plugins.colorChannel.process(imageIn, imageOut, null, MarvinImageMask.NULL_MASK, false); 52 | }; 53 | 54 | // Color Channel 55 | Marvin.plugins.crop = new Crop(); 56 | Marvin.crop = function(imageIn, imageOut, x, y, width, height){ 57 | Marvin.plugins.crop.setAttribute("x", x); 58 | Marvin.plugins.crop.setAttribute("y", y); 59 | Marvin.plugins.crop.setAttribute("width", width); 60 | Marvin.plugins.crop.setAttribute("height", height); 61 | Marvin.plugins.crop.process(imageIn, imageOut, null, MarvinImageMask.NULL_MASK, false); 62 | }; 63 | 64 | // Combine by Alpha 65 | Marvin.plugins.combineByAlpha = new CombineByAlpha(); 66 | Marvin.combineByAlpha = function(imageIn, imageOther, imageOut, x, y){ 67 | Marvin.plugins.combineByAlpha.setAttribute("imageOther", imageOther); 68 | Marvin.plugins.combineByAlpha.setAttribute("x", x); 69 | Marvin.plugins.combineByAlpha.setAttribute("y", y); 70 | Marvin.plugins.combineByAlpha.process(imageIn, imageOut, null, MarvinImageMask.NULL_MASK, false); 71 | }; 72 | 73 | // Emboss 74 | Marvin.plugins.emboss = new Emboss(); 75 | Marvin.emboss = function(imageIn, imageOut){ 76 | Marvin.plugins.emboss.process(imageIn, imageOut, null, MarvinImageMask.NULL_MASK, false); 77 | }; 78 | 79 | // Emboss 80 | Marvin.plugins.halftoneErrorDiffusion = new ErrorDiffusion(); 81 | Marvin.halftoneErrorDiffusion = function(imageIn, imageOut){ 82 | Marvin.plugins.halftoneErrorDiffusion.process(imageIn, imageOut, null, MarvinImageMask.NULL_MASK, false); 83 | }; 84 | 85 | // FindTextRegions 86 | Marvin.plugins.findTextRegions = new FindTextRegions(); 87 | Marvin.findTextRegions = function(imageIn, maxWhiteSpace, maxFontLineWidth, minTextWidth, grayScaleThreshold){ 88 | var attrOut = new MarvinAttributes(); 89 | Marvin.plugins.findTextRegions.setAttribute("maxWhiteSpace", Marvin.getValue(maxWhiteSpace, 10)); 90 | Marvin.plugins.findTextRegions.setAttribute("maxFontLineWidth", Marvin.getValue(maxFontLineWidth, 10)); 91 | Marvin.plugins.findTextRegions.setAttribute("minTextWidth", Marvin.getValue(minTextWidth, 30)); 92 | Marvin.plugins.findTextRegions.setAttribute("grayScaleThreshold", Marvin.getValue(grayScaleThreshold, 127)); 93 | Marvin.plugins.findTextRegions.process(imageIn, null, attrOut, MarvinImageMask.NULL_MASK, false); 94 | return attrOut.get("matches"); 95 | }; 96 | 97 | // Floodfill Segmentation 98 | Marvin.plugins.floodfillSegmentation = new FloodfillSegmentation(); 99 | Marvin.floodfillSegmentation = function(imageIn){ 100 | var attrOut = new MarvinAttributes(); 101 | Marvin.plugins.floodfillSegmentation.setAttribute("returnType", "MarvinSegment"); 102 | Marvin.plugins.floodfillSegmentation.process(imageIn, null, attrOut, MarvinImageMask.NULL_MASK, false); 103 | return attrOut.get("segments"); 104 | }; 105 | 106 | // Gaussian Blur 107 | Marvin.plugins.gaussianBlur = new GaussianBlur(); 108 | Marvin.gaussianBlur = function(imageIn, imageOut, radius){ 109 | Marvin.plugins.gaussianBlur.setAttribute("radius", Marvin.getValue(radius, 3.0)); 110 | Marvin.plugins.gaussianBlur.process(imageIn, imageOut, null, MarvinImageMask.NULL_MASK, false); 111 | }; 112 | 113 | // Invert 114 | Marvin.plugins.invertColors = new Invert(); 115 | Marvin.invertColors = function(imageIn, imageOut){ 116 | Marvin.plugins.invertColors.process(imageIn, imageOut, null, MarvinImageMask.NULL_MASK, false); 117 | }; 118 | 119 | Marvin.plugins.iteratedFunctionSystem = new IteratedFunctionSystem(); 120 | Marvin.iteratedFunctionSystem = function(imageIn, imageOut, rules, iterations){ 121 | Marvin.plugins.iteratedFunctionSystem.setAttribute("rules", rules); 122 | Marvin.plugins.iteratedFunctionSystem.setAttribute("iterations", iterations); 123 | Marvin.plugins.iteratedFunctionSystem.process(imageIn, imageOut, null, MarvinImageMask.NULL_MASK, false); 124 | }; 125 | 126 | // GrayScale 127 | Marvin.plugins.grayScale = new GrayScale(); 128 | Marvin.grayScale = function(imageIn, imageOut){ 129 | Marvin.plugins.grayScale.process(imageIn, imageOut, null, MarvinImageMask.NULL_MASK, false); 130 | }; 131 | 132 | //Merge Photos 133 | Marvin.plugins.mergePhotos = new MergePhotos(); 134 | Marvin.mergePhotos = function(images, imageOut, threshold){ 135 | Marvin.plugins.mergePhotos.setAttribute("threshold", threshold); 136 | Marvin.plugins.mergePhotos.process(images, imageOut); 137 | }; 138 | 139 | // Moravec 140 | Marvin.plugins.moravec = new Moravec(); 141 | Marvin.moravec = function(imageIn, imageOut, matrixSize, threshold){ 142 | var attrOut = new MarvinAttributes(); 143 | Marvin.plugins.moravec.setAttribute("matrixSize", matrixSize); 144 | Marvin.plugins.moravec.setAttribute("threshold", threshold); 145 | Marvin.plugins.moravec.process(imageIn, imageOut, attrOut, MarvinImageMask.NULL_MASK, false); 146 | return attrOut.get("cornernessMap"); 147 | }; 148 | 149 | // Morphological Dilation 150 | Marvin.plugins.morphologicalDilation = new Dilation(); 151 | Marvin.morphologicalDilation = function(imageIn, imageOut, matrix){ 152 | Marvin.plugins.morphologicalDilation.setAttribute("matrix", matrix); 153 | Marvin.plugins.morphologicalDilation.process(imageIn, imageOut, null, MarvinImageMask.NULL_MASK, false); 154 | }; 155 | 156 | // Morphological Erosion 157 | Marvin.plugins.morphologicalErosion = new Erosion(); 158 | Marvin.morphologicalErosion = function(imageIn, imageOut, matrix){ 159 | Marvin.plugins.morphologicalErosion.setAttribute("matrix", matrix); 160 | Marvin.plugins.morphologicalErosion.process(imageIn, imageOut, null, MarvinImageMask.NULL_MASK, false); 161 | }; 162 | 163 | // Morphological Closing 164 | Marvin.plugins.morphologicalClosing = new Closing(); 165 | Marvin.morphologicalClosing = function(imageIn, imageOut, matrix){ 166 | Marvin.plugins.morphologicalClosing.setAttribute("matrix", matrix); 167 | Marvin.plugins.morphologicalClosing.process(imageIn, imageOut, null, MarvinImageMask.NULL_MASK, false); 168 | }; 169 | 170 | // Prewitt 171 | Marvin.plugins.prewitt = new Prewitt(); 172 | Marvin.prewitt = function(imageIn, imageOut, intensity){ 173 | Marvin.plugins.prewitt.setAttribute("intensity", Marvin.getValue(intensity, 1.0)); 174 | Marvin.plugins.prewitt.process(imageIn, imageOut, null, MarvinImageMask.NULL_MASK, false); 175 | }; 176 | 177 | // Scale 178 | Marvin.plugins.scale = new Scale(); 179 | Marvin.scale = function(imageIn, imageOut, newWidth, newHeight){ 180 | 181 | if(newHeight == null){ 182 | var factor = imageIn.getHeight() / imageIn.getWidth(); 183 | newHeight = Math.floor(factor * newWidth); 184 | } 185 | 186 | Marvin.plugins.scale.setAttribute("newWidth", newWidth); 187 | Marvin.plugins.scale.setAttribute("newHeight", newHeight); 188 | Marvin.plugins.scale.process(imageIn, imageOut, null, MarvinImageMask.NULL_MASK, false); 189 | }; 190 | 191 | // Sepia 192 | Marvin.plugins.sepia = new Sepia(); 193 | Marvin.sepia = function(imageIn, imageOut, intensity){ 194 | Marvin.plugins.sepia.setAttribute("intensity", intensity); 195 | Marvin.plugins.sepia.process(imageIn, imageOut, null, MarvinImageMask.NULL_MASK, false); 196 | }; 197 | 198 | // Thresholding 199 | Marvin.plugins.thresholding = new Thresholding(); 200 | Marvin.thresholding = function(imageIn, imageOut, threshold, thresholdRange){ 201 | Marvin.plugins.thresholding.setAttribute("threshold", threshold); 202 | Marvin.plugins.thresholding.setAttribute("thresholdRange", thresholdRange); 203 | Marvin.plugins.thresholding.process(imageIn, imageOut, null, MarvinImageMask.NULL_MASK, false); 204 | }; 205 | 206 | // ThresholdingNeighborhood 207 | Marvin.plugins.thresholdingNeighborhood = new ThresholdingNeighborhood(); 208 | Marvin.thresholdingNeighborhood = function(imageIn, imageOut, thresholdPercentageOfAverage, neighborhoodSide, samplingPixelDistance){ 209 | Marvin.plugins.thresholdingNeighborhood.setAttribute("thresholdPercentageOfAverage", thresholdPercentageOfAverage); 210 | Marvin.plugins.thresholdingNeighborhood.setAttribute("neighborhoodSide", neighborhoodSide); 211 | Marvin.plugins.thresholdingNeighborhood.setAttribute("samplingPixelDistance", samplingPixelDistance); 212 | Marvin.plugins.thresholdingNeighborhood.process(imageIn, imageOut, null, MarvinImageMask.NULL_MASK, false); 213 | }; 214 | } 215 | 216 | var Marvin = new Object(); 217 | 218 | Marvin.getValue = function(value, defaultValue){ 219 | if(value != null){ 220 | return value; 221 | } else { 222 | return defaultValue; 223 | } 224 | } 225 | 226 | marvinLoadPluginMethods(); 227 | -------------------------------------------------------------------------------- /marvinj/src/MarvinJSUtils.js: -------------------------------------------------------------------------------- 1 | var MarvinJSUtils = new Object(); 2 | 3 | MarvinJSUtils.createMatrix2D = function(rows, cols, value){ 4 | var arr = new Array(rows); 5 | for(var i=0; i>> 16; 43 | green = (rgbArray[i] & 0x00FF00) >>> 8; 44 | blue = (rgbArray[i] & 0x0000FF); 45 | 46 | red /=255.0; 47 | green /=255.0; 48 | blue /=255.0; 49 | 50 | var max = Math.max(Math.max(red, green), blue); 51 | var min = Math.min(Math.min(red, green), blue); 52 | var c = max-min; 53 | 54 | // H 55 | var h,s,v; 56 | if(c !=0 ){ 57 | if(max == red){ 58 | if(green >= blue){ 59 | h = 60 * ((green-blue)/c); 60 | } else{ 61 | h = 60 * ((green-blue)/c) + 360; 62 | } 63 | } else if(max == green){ 64 | h = 60 * ((blue-red)/c) + 120; 65 | } else{ 66 | h = 60 * ((red-green)/c) + 240; 67 | } 68 | } else{ 69 | h = 0; 70 | } 71 | 72 | 73 | // V 74 | v = max; 75 | 76 | // S 77 | s = (c!=0? c/v : 0); 78 | 79 | hsvArray[(i*3)] = h; 80 | hsvArray[(i*3)+1] = s; 81 | hsvArray[(i*3)+2] = v; 82 | 83 | } 84 | return hsvArray; 85 | }; 86 | 87 | MarvinColorModelConverter.hsvToRgb = function(hsvArray){ 88 | var rgbArray = new Array(hsvArray.length/3); 89 | 90 | for(var i=0, j=0; i>> 24; 142 | var r = (color & 0x00FF0000) >> 16; 143 | var g = (color & 0x0000FF00) >> 8; 144 | var b = color & 0x000000FF; 145 | this.setIntColor4(x,y,a,r,g,b); 146 | }; 147 | 148 | MarvinImage.prototype.setBinaryColor = function(x,y,value){ 149 | var pos = ((y*this.getWidth())+x); 150 | this.arrBinaryColor[pos] = value; 151 | }; 152 | 153 | MarvinImage.prototype.getBinaryColor = function(x,y){ 154 | var pos = ((y*this.getWidth())+x); 155 | return this.arrBinaryColor[pos]; 156 | }; 157 | 158 | MarvinImage.copyColorArray = function(imgSource, imgDestine){ 159 | 160 | if(imgSource.getColorModel() == imgDestine.getColorModel()){ 161 | switch(imgSource.getColorModel()){ 162 | case MarvinImage.COLOR_MODEL_RGB: 163 | for(var i=0; i> 16; 220 | var g = (color & 0x0000FF00) >> 8; 221 | var b = color & 0x000000FF; 222 | this.setIntColor4(x,y,alpha,r,g,b); 223 | }; 224 | 225 | MarvinImage.prototype.setIntColor3 = function(x,y, r, g, b){ 226 | this.setIntColor4(x,y,255,r,g,b); 227 | }; 228 | 229 | MarvinImage.prototype.setIntColor4 = function(x,y, alpha, r, g, b){ 230 | var start = ((y*this.getWidth())+x)*4; 231 | this.imageData.data[start] = r; 232 | this.imageData.data[start+1] = g; 233 | this.imageData.data[start+2] = b; 234 | this.imageData.data[start+3] = alpha; 235 | }; 236 | 237 | MarvinImage.prototype.getWidth = function(){ 238 | return this.width; 239 | }; 240 | 241 | MarvinImage.prototype.getHeight = function(){ 242 | return this.height; 243 | }; 244 | 245 | MarvinImage.prototype.isValidPosition = function(x, y){ 246 | if(x >= 0 && x < this.width && y >= 0 && y < this.height){ 247 | return true; 248 | } 249 | return false; 250 | }; 251 | 252 | MarvinImage.prototype.draw = function(canvas, x, y, alphaCombination){ 253 | if(x == null){x=0;} 254 | if(y == null){y=0;} 255 | canvas.getContext("2d").putImageData(this.imageData, x,y);/* 256 | if(alphaCombination == null || !alphaCombination){ 257 | canvas.getContext("2d").putImageData(this.imageData, x,y); 258 | } else{ 259 | this.imageData = this.ctx.getImageData(0, 0, width, height); 260 | var c = document.createElement('canvas'); 261 | c.width = this.width; 262 | c.height = this.height; 263 | c.getContext('2d').putImageData(this.imageData,x,y); 264 | var img = new Image(); 265 | img.src = c.toDataURL(); 266 | canvas.getContext("2d").drawImage(img, x, y); 267 | }*/ 268 | }; 269 | 270 | MarvinImage.prototype.toBlob = function(){ 271 | this.update(); 272 | return MarvinImage.dataURItoBlob(this.canvas.toDataURL("image/png")); 273 | }; 274 | 275 | MarvinImage.dataURItoBlob = function(dataURI) { 276 | // convert base64/URLEncoded data component to raw binary data held in a string 277 | var byteString; 278 | if (dataURI.split(',')[0].indexOf('base64') >= 0) 279 | byteString = atob(dataURI.split(',')[1]); 280 | else 281 | byteString = unescape(dataURI.split(',')[1]); 282 | 283 | // separate out the mime component 284 | var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]; 285 | 286 | // write the bytes of the string to a typed array 287 | var ia = new Uint8Array(byteString.length); 288 | for (var i = 0; i < byteString.length; i++) { 289 | ia[i] = byteString.charCodeAt(i); 290 | } 291 | 292 | return new Blob([ia], {type:mimeString}); 293 | } 294 | -------------------------------------------------------------------------------- /marvinj/src/image/MarvinImageMask.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | function MarvinImageMask (w, h){ 4 | this.width = w; 5 | this.height = h; 6 | 7 | if(w != 0 && h != 0){ 8 | this.arrMask = MarvinJSUtils.createMatrix2D(width, height); 9 | } else{ 10 | this.arrMask = null; 11 | } 12 | }; 13 | 14 | MarvinImageMask.prototype.getWidth = function(){ 15 | return this.width; 16 | }; 17 | 18 | MarvinImageMask.prototype.getHeight = function(){ 19 | return this.height; 20 | }; 21 | 22 | MarvinImageMask.prototype.addPixel = function(x, y){ 23 | this.arrMask[x][y] = true; 24 | }; 25 | 26 | MarvinImageMask.prototype.removePixel = function(x, y){ 27 | this.arrMask[x][y] = false; 28 | }; 29 | 30 | MarvinImageMask.prototype.clear = function(){ 31 | if(this.arrMask != null){ 32 | for(var y=0; y max){ 51 | max = arr[i]; 52 | maxIndex = i; 53 | } 54 | } 55 | 56 | return maxIndex*10; 57 | } 58 | 59 | -------------------------------------------------------------------------------- /marvinj/src/plugins/background/DetermineSceneBackground.js: -------------------------------------------------------------------------------- 1 | function DetermineSceneBackground(){ 2 | MarvinAbstractImagePlugin.super(this); 3 | this.load(); 4 | } 5 | 6 | DetermineSceneBackground.prototype.load = function() { 7 | this.setAttribute("threshold", 30); 8 | } 9 | 10 | 11 | DetermineSceneBackground.prototype.process = function 12 | ( 13 | images, 14 | imageOut 15 | ) 16 | { 17 | var threshold = this.getAttribute("threshold"); 18 | var image0 = images[0]; 19 | for(var y=0; y max){ 70 | max = c2[3]; 71 | maxIndex = i; 72 | } 73 | } 74 | c2 = colors[maxIndex]; 75 | return 0xFF000000 + (c2[0] << 16) + (c2[1] << 8) + c2[2]; 76 | } 77 | -------------------------------------------------------------------------------- /marvinj/src/plugins/blur/GaussianBlur.js: -------------------------------------------------------------------------------- 1 | function GaussianBlur(){ 2 | MarvinAbstractImagePlugin.super(this); 3 | this.load(); 4 | } 5 | 6 | GaussianBlur.prototype.load = function(){ 7 | 8 | this.RED = 0; 9 | this.GREEN = 1; 10 | this.BLUE = 2; 11 | 12 | this.kernelMatrix = null; 13 | this.resultMatrix = null; 14 | this.appiledkernelMatrix = null; 15 | this.radius = null; 16 | 17 | this.setAttribute("radius",3); 18 | } 19 | 20 | GaussianBlur.prototype.process = function 21 | ( 22 | imageIn, 23 | imageOut, 24 | attributesOut, 25 | mask, 26 | previewMode 27 | ) 28 | { 29 | this.radius = this.getAttribute("radius"); 30 | 31 | var l_imageWidth = imageIn.getWidth(); 32 | var l_imageHeight = imageIn.getHeight(); 33 | 34 | var l_pixelColor; 35 | this.kernelMatrix = this.getGaussianKernel(); 36 | this.resultMatrix = MarvinJSUtils.createMatrix3D(l_imageWidth, l_imageHeight, 3, 0); 37 | this.appiledkernelMatrix = MarvinJSUtils.createMatrix2D(l_imageWidth, l_imageHeight, 0); 38 | 39 | var l_arrMask = mask.getMask(); 40 | 41 | for (var x = 0; x < l_imageWidth; x++) { 42 | for (var y = 0; y < l_imageHeight; y++) { 43 | if(l_arrMask != null && !l_arrMask[x][y]){ 44 | continue; 45 | } 46 | l_pixelColor = imageIn.getIntColor(x,y); 47 | this.applyKernel(x,y,l_pixelColor,imageOut); 48 | } 49 | } 50 | 51 | for (var x = 0; x < l_imageWidth; x++) { 52 | for (var y = 0; y < l_imageHeight; y++) { 53 | if(l_arrMask != null && !l_arrMask[x][y]){ 54 | continue; 55 | } 56 | this.resultMatrix[x][y][this.RED] = ((this.resultMatrix[x][y][0]/this.appiledkernelMatrix[x][y])%256); 57 | this.resultMatrix[x][y][this.GREEN] = ((this.resultMatrix[x][y][1]/this.appiledkernelMatrix[x][y])%256); 58 | this.resultMatrix[x][y][this.BLUE] = ((this.resultMatrix[x][y][2]/this.appiledkernelMatrix[x][y])%256); 59 | imageOut.setIntColor(x,y,imageIn.getAlphaComponent(x, y), Math.floor(this.resultMatrix[x][y][0]), Math.floor(this.resultMatrix[x][y][1]), Math.floor(this.resultMatrix[x][y][2])); 60 | } 61 | } 62 | } 63 | 64 | /* 65 | * Calc Gaussian Matrix. 66 | */ 67 | GaussianBlur.prototype.getGaussianKernel = function(){ 68 | var l_matrix = MarvinJSUtils.createMatrix2D((this.radius*2)+1, (this.radius*2)+1); 69 | var l_q=this.radius/3.0; 70 | var l_distance; 71 | var l_x; 72 | var l_y; 73 | 74 | for(var x=1; x<=(this.radius*2)+1; x++){ 75 | for(var y=1; y<=(this.radius*2)+1; y++){ 76 | l_x = Math.abs(x-(this.radius+1)); 77 | l_y = Math.abs(y-(this.radius+1)); 78 | l_distance = Math.sqrt((l_x*l_x)+(l_y*l_y)); 79 | l_matrix[y-1][x-1] = ( (1.0/(2.0*Math.PI*l_q*l_q))* Math.exp( (-(l_distance*l_distance)) / (2.0*l_q*l_q) ) ); 80 | } 81 | } 82 | return l_matrix; 83 | } 84 | 85 | /* 86 | * Apply the blur matrix on a image region. 87 | */ 88 | GaussianBlur.prototype.applyKernel = function(centerPixel_X, centerPixel_Y, pixelColor, image) 89 | { 90 | for(var y=centerPixel_Y; y= 0 && x-this.radius < image.getWidth() && y-this.radius >= 0 && y-this.radius < image.getHeight()){ 93 | this.resultMatrix[x-this.radius][y-this.radius][this.RED]+= (((pixelColor & 0x00FF0000) >>> 16)*this.kernelMatrix[x-centerPixel_X][y-centerPixel_Y]); 94 | this.resultMatrix[x-this.radius][y-this.radius][this.GREEN]+= (((pixelColor & 0x0000FF00) >>> 8)*this.kernelMatrix[x-centerPixel_X][y-centerPixel_Y]); 95 | this.resultMatrix[x-this.radius][y-this.radius][this.BLUE]+= ((pixelColor & 0x000000FF)*this.kernelMatrix[x-centerPixel_X][y-centerPixel_Y]); 96 | this.appiledkernelMatrix[x-this.radius][y-this.radius] += this.kernelMatrix[x-centerPixel_X][y-centerPixel_Y]; 97 | } 98 | } 99 | } 100 | } -------------------------------------------------------------------------------- /marvinj/src/plugins/color/AlphaBoundary.js: -------------------------------------------------------------------------------- 1 | function AlphaBoundary(){ 2 | MarvinAbstractImagePlugin.super(this); 3 | this.load(); 4 | } 5 | 6 | AlphaBoundary.prototype.load = function(){ 7 | this.setAttribute("radius", 5); 8 | }; 9 | 10 | AlphaBoundary.prototype.process = function 11 | ( 12 | imageIn, 13 | imageOut, 14 | attributesOut, 15 | mask, 16 | previewMode 17 | ) 18 | { 19 | var neighborhood = this.getAttribute("radius"); 20 | for(var y=0; y= 0 && i< image.getWidth() && j >= 0 && j < image.getHeight()){ 39 | totalAlpha += image.getAlphaComponent(i, j); 40 | totalPixels++; 41 | } 42 | } 43 | } 44 | 45 | newAlpha = Math.floor(totalAlpha/totalPixels); 46 | 47 | if(newAlpha < oldAlpha) 48 | image.setAlphaComponent(x, y, newAlpha); 49 | }; 50 | 51 | -------------------------------------------------------------------------------- /marvinj/src/plugins/color/AverageColor.js: -------------------------------------------------------------------------------- 1 | function AverageColor(){ 2 | MarvinAbstractImagePlugin.super(this); 3 | this.load(); 4 | } 5 | 6 | AverageColor.prototype.load = function(){ 7 | }; 8 | 9 | AverageColor.prototype.process = function 10 | ( 11 | imageIn, 12 | imageOut, 13 | attributesOut, 14 | mask, 15 | previewMode 16 | ) 17 | { 18 | 19 | var totalR=0; 20 | var totalG=0; 21 | var totalB=0; 22 | 23 | for (var x = 0; x < imageIn.getWidth(); x++) { 24 | for (var y = 0; y < imageIn.getHeight(); y++) { 25 | totalR += imageIn.getIntComponent0(x,y); 26 | totalG += imageIn.getIntComponent1(x,y); 27 | totalB += imageIn.getIntComponent2(x,y); 28 | } 29 | } 30 | 31 | var totalPixels = imageIn.getWidth()*imageIn.getHeight(); 32 | totalR = Math.round(totalR/totalPixels); 33 | totalG = Math.round(totalG/totalPixels); 34 | totalB = Math.round(totalB/totalPixels); 35 | 36 | if(attributesOut != null){ 37 | attributesOut.set("averageColor", [totalR, totalG, totalB]); 38 | } 39 | }; -------------------------------------------------------------------------------- /marvinj/src/plugins/color/BlackAndWhite.js: -------------------------------------------------------------------------------- 1 | 2 | function BlackAndWhite(){ 3 | MarvinAbstractImagePlugin.super(this); 4 | this.MAX_RLEVEL = 0.03; 5 | this.load(); 6 | } 7 | 8 | BlackAndWhite.prototype.load = function() { 9 | this.grayScale = new GrayScale(); 10 | this.setAttribute("level", 10); 11 | } 12 | 13 | BlackAndWhite.prototype.process = function 14 | ( 15 | imageIn, 16 | imageOut, 17 | attributesOut, 18 | mask, 19 | previewMode 20 | ) 21 | { 22 | this.grayScale.process(imageIn, imageOut); 23 | var level = this.getAttribute("level"); 24 | var rlevel = (level/100.0)*this.MAX_RLEVEL; 25 | 26 | var c=0; 27 | var gray; 28 | for(var y=0; y 255) r=255; 38 | if(g < 0) g=0; 39 | if(g > 255) g=255; 40 | if(b < 0) b=0; 41 | if(b > 255) b=255; 42 | 43 | imageOut.setIntColor(x,y,imageIn.getAlphaComponent(x, y), Math.floor(r),Math.floor(g),Math.floor(b)); 44 | } 45 | } 46 | 47 | // Contrast 48 | for (var x = 0; x < imageIn.getWidth(); x++) { 49 | for (var y = 0; y < imageIn.getHeight(); y++) { 50 | r = imageOut.getIntComponent0(x, y); 51 | g = imageOut.getIntComponent1(x, y); 52 | b = imageOut.getIntComponent2(x, y); 53 | 54 | 55 | r /= 255.0; 56 | r -= 0.5; 57 | r *= l_contrast; 58 | r += 0.5; 59 | r *= 255.0; 60 | 61 | g /= 255.0; 62 | g -= 0.5; 63 | g *= l_contrast; 64 | g += 0.5; 65 | g *= 255.0; 66 | 67 | b /= 255.0; 68 | b -= 0.5; 69 | b *= l_contrast; 70 | b += 0.5; 71 | b *= 255.0; 72 | 73 | 74 | if(r < 0) r=0; 75 | if(r > 255) r=255; 76 | if(g < 0) g=0; 77 | if(g > 255) g=255; 78 | if(b < 0) b=0; 79 | if(b > 255) b=255; 80 | 81 | imageOut.setIntColor(x,y,imageIn.getAlphaComponent(x, y), Math.floor(r),Math.floor(g),Math.floor(b)); 82 | } 83 | } 84 | }; 85 | -------------------------------------------------------------------------------- /marvinj/src/plugins/color/ColorChannel.js: -------------------------------------------------------------------------------- 1 | 2 | function ColorChannel(){ 3 | MarvinAbstractImagePlugin.super(this); 4 | this.load(); 5 | } 6 | 7 | ColorChannel.prototype.load = function() { 8 | this.setAttribute("red", 0); 9 | this.setAttribute("green", 0); 10 | this.setAttribute("blue", 0); 11 | } 12 | 13 | ColorChannel.prototype.process = function 14 | ( 15 | imageIn, 16 | imageOut, 17 | attributesOut, 18 | mask, 19 | previewMode 20 | ) 21 | { 22 | 23 | var vr = this.getAttribute("red"); 24 | var vg = this.getAttribute("green"); 25 | var vb = this.getAttribute("blue"); 26 | 27 | var mr = 1+Math.abs((vr/100.0)*2.5); 28 | var mg = 1+Math.abs((vg/100.0)*2.5); 29 | var mb = 1+Math.abs((vb/100.0)*2.5); 30 | 31 | mr = (vr > 0? mr : 1.0/mr); 32 | mg = (vg > 0? mg : 1.0/mg); 33 | mb = (vb > 0? mb : 1.0/mb); 34 | 35 | var red,green,blue; 36 | for(var y=0; y 0 && x > 0){ 32 | 33 | // Red component difference between the current and the upperleft pixels 34 | rDiff = imageIn.getIntComponent0(x, y) - imageIn.getIntComponent0(x-1, y-1); 35 | 36 | // Green component difference between the current and the upperleft pixels 37 | gDiff = imageIn.getIntComponent1(x, y) - imageIn.getIntComponent1(x-1, y-1); 38 | 39 | // Blue component difference between the current and the upperleft pixels 40 | bDiff = imageIn.getIntComponent2(x, y) - imageIn.getIntComponent2(x-1, y-1); 41 | 42 | } 43 | else{ 44 | rDiff = 0; 45 | gDiff = 0; 46 | bDiff = 0; 47 | } 48 | 49 | var diff = rDiff; 50 | if (Math.abs (gDiff) > Math.abs (diff)) 51 | diff = gDiff; 52 | if (Math.abs (bDiff) > Math.abs (diff)) 53 | diff = bDiff; 54 | 55 | var grayLevel = Math.max (Math.min (128 + diff, 255),0); 56 | 57 | imageOut.setIntColor(x, y, 255, grayLevel, grayLevel, grayLevel); 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /marvinj/src/plugins/color/GrayScale.js: -------------------------------------------------------------------------------- 1 | 2 | function GrayScale(){ 3 | MarvinAbstractImagePlugin.super(this); 4 | this.load(); 5 | } 6 | 7 | GrayScale.prototype.load = function(){}; 8 | 9 | GrayScale.prototype.process = function 10 | ( 11 | imageIn, 12 | imageOut, 13 | attributesOut, 14 | mask, 15 | previewMode 16 | ) 17 | { 18 | // Mask 19 | var l_arrMask; 20 | if(mask != null){ 21 | l_arrMask = mask.getMask(); 22 | } 23 | 24 | var r,g,b,finalColor; 25 | for (var x = 0; x < imageIn.getWidth(); x++) { 26 | for (var y = 0; y < imageIn.getHeight(); y++) { 27 | if(l_arrMask != null && !l_arrMask[x][y]){ 28 | continue; 29 | } 30 | //Red - 30% / Green - 59% / Blue - 11% 31 | r = imageIn.getIntComponent0(x, y); 32 | g = imageIn.getIntComponent1(x, y); 33 | b = imageIn.getIntComponent2(x, y); 34 | finalColor = Math.ceil((r*0.3)+(g*0.59)+(b*0.11)); 35 | imageOut.setIntColor(x,y,imageIn.getAlphaComponent(x, y), finalColor,finalColor,finalColor); 36 | 37 | } 38 | } 39 | }; 40 | 41 | -------------------------------------------------------------------------------- /marvinj/src/plugins/color/Invert.js: -------------------------------------------------------------------------------- 1 | function Invert(){ 2 | MarvinAbstractImagePlugin.super(this); 3 | this.load(); 4 | } 5 | 6 | Invert.prototype.load = function(){} 7 | 8 | Invert.prototype.process = function 9 | ( 10 | imageIn, 11 | imageOut, 12 | attributesOut, 13 | mask, 14 | previewMode 15 | ) 16 | { 17 | var l_arrMask = mask.getMask(); 18 | 19 | var r, g, b; 20 | for (var x = 0; x < imageIn.getWidth(); x++) { 21 | for (var y = 0; y < imageIn.getHeight(); y++) { 22 | if(l_arrMask != null && !l_arrMask[x][y]){ 23 | continue; 24 | } 25 | r = (255-imageIn.getIntComponent0(x, y)); 26 | g = (255-imageIn.getIntComponent1(x, y)); 27 | b = (255-imageIn.getIntComponent2(x, y)); 28 | 29 | imageOut.setIntColor(x,y,imageIn.getAlphaComponent(x, y), r,g,b); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /marvinj/src/plugins/color/Sepia.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/src/plugins/color/Sepia.js -------------------------------------------------------------------------------- /marvinj/src/plugins/color/Thresholding.js: -------------------------------------------------------------------------------- 1 | function Thresholding(){ 2 | MarvinAbstractImagePlugin.super(this); 3 | this.load(); 4 | 5 | this.threshold = null; 6 | this.thresholdRange = null; 7 | this.neighborhood = null; 8 | this.range = null; 9 | } 10 | 11 | Thresholding.prototype.load = function(){ 12 | 13 | // Attributes 14 | this.setAttribute("threshold", 125); 15 | this.setAttribute("thresholdRange", -1); 16 | this.setAttribute("neighborhood", -1); 17 | this.setAttribute("range", -1); 18 | 19 | this.pluginGray = new GrayScale(); 20 | } 21 | 22 | Thresholding.prototype.process = function 23 | ( 24 | imageIn, 25 | imageOut, 26 | attributesOut, 27 | mask, 28 | previewMode 29 | ) 30 | { 31 | this.threshold = this.getAttribute("threshold"); 32 | this.thresholdRange = this.getAttribute("thresholdRange"); 33 | this.neighborhood = this.getAttribute("neighborhood"); 34 | this.range = this.getAttribute("range"); 35 | 36 | if(this.thresholdRange == -1){ 37 | this.thresholdRange = 255-threshold; 38 | } 39 | 40 | this.pluginGray.process(imageIn, imageOut, attributesOut, mask, previewMode); 41 | 42 | var bmask = mask.getMask(); 43 | 44 | if(this.neighborhood == -1 && this.range == -1){ 45 | this.hardThreshold(imageIn, imageOut, bmask); 46 | } 47 | else{ 48 | this.contrastThreshold(imageIn, imageOut); 49 | } 50 | 51 | } 52 | 53 | Thresholding.prototype.hardThreshold = function(imageIn, imageOut, mask){ 54 | for(var y=0; y this.threshold+this.thresholdRange){ 62 | imageOut.setIntColor(x, y, imageIn.getAlphaComponent(x,y), 0,0,0); 63 | } 64 | else{ 65 | imageOut.setIntColor(x, y, imageIn.getAlphaComponent(x,y), 255,255,255); 66 | } 67 | } 68 | } 69 | } 70 | 71 | Thresholding.prototype.contrastThreshold = function(imageIn, imageOut){ 72 | this.range = 1; 73 | for (var x = 0; x < imageIn.getWidth(); x++) { 74 | for (var y = 0; y < imageIn.getHeight(); y++) { 75 | if(checkNeighbors(x,y, neighborhood, neighborhood, imageIn)){ 76 | imageOut.setIntColor(x,y,0,0,0); 77 | } 78 | else{ 79 | imageOut.setIntColor(x,y,255,255,255); 80 | } 81 | } 82 | } 83 | } 84 | 85 | Thresholding.prototype.checkNeighbors = function(x, y, neighborhoodX, neighborhoodY, img){ 86 | 87 | var color; 88 | var z=0; 89 | 90 | color = img.getIntComponent0(x, y); 91 | 92 | for(var i=0-neighborhoodX; i<=neighborhoodX; i++){ 93 | for(var j=0-neighborhoodY; j<=neighborhoodY; j++){ 94 | if(i == 0 && j == 0){ 95 | continue; 96 | } 97 | 98 | if(color < getSafeColor(x+i,y+j, img)-range && getSafeColor(x+i,y+j, img) != -1){ 99 | z++; 100 | } 101 | } 102 | } 103 | 104 | if(z > (neighborhoodX*neighborhoodY)*0.5){ 105 | return true; 106 | } 107 | 108 | return false; 109 | }; 110 | 111 | Thresholding.prototype.getSafeColor = function(x, y, img){ 112 | 113 | if(x >= 0 && x < img.getWidth() && y >= 0 && y < img.getHeight()){ 114 | return img.getIntComponent0(x, y); 115 | } 116 | return -1; 117 | }; 118 | -------------------------------------------------------------------------------- /marvinj/src/plugins/color/ThresholdingNeighborhood.js: -------------------------------------------------------------------------------- 1 | function ThresholdingNeighborhood(){ 2 | MarvinAbstractImagePlugin.super(this); 3 | this.load(); 4 | } 5 | 6 | ThresholdingNeighborhood.prototype.load = function() { 7 | this.setAttribute("neighborhoodSide", 10); 8 | this.setAttribute("samplingPixelDistance", 1); 9 | this.setAttribute("thresholdPercentageOfAverage", 1.0); 10 | } 11 | 12 | ThresholdingNeighborhood.prototype.process = function 13 | ( 14 | imageIn, 15 | imageOut, 16 | attributesOut, 17 | mask, 18 | previewMode 19 | ) 20 | { 21 | var neighborhoodSide = this.getAttribute("neighborhoodSide"); 22 | var samplingPixelDistance = this.getAttribute("samplingPixelDistance"); 23 | var thresholdPercentageOfAverage = this.getAttribute("thresholdPercentageOfAverage"); 24 | 25 | for(var y=0; y= 0 && j>= 0 && i < image.getWidth() && j < image.getHeight()){ 46 | 47 | var color = image.getIntComponent0(i,j); 48 | 49 | if(min == -1 || color < min){ 50 | min = color; 51 | } 52 | if(max == -1 || color > max){ 53 | max = color; 54 | } 55 | 56 | average+=color; 57 | pixels++; 58 | } 59 | } 60 | } 61 | 62 | average /= pixels; 63 | 64 | var color = image.getIntComponent0(x,y); 65 | 66 | if(color < average*thresholdPercentageOfAverage || (max-min) <= 30){ 67 | imageOut.setIntColor(x, y, 255, 0, 0, 0); 68 | } else{ 69 | imageOut.setIntColor(x, y, 255, 255, 255, 255); 70 | } 71 | }; 72 | -------------------------------------------------------------------------------- /marvinj/src/plugins/combine/CombineByAlpha.js: -------------------------------------------------------------------------------- 1 | function CombineByAlpha(){ 2 | MarvinAbstractImagePlugin.super(this); 3 | this.load(); 4 | } 5 | 6 | CombineByAlpha.prototype.load = function(){ 7 | this.setAttribute("x", 0); 8 | this.setAttribute("y", 0); 9 | this.setAttribute("imageOther", null); 10 | } 11 | 12 | CombineByAlpha.prototype.process = function 13 | ( 14 | imageIn, 15 | imageOut, 16 | attributesOut, 17 | mask, 18 | previewMode 19 | ) 20 | { 21 | var imageOther = this.getAttribute("imageOther"); 22 | var x = this.getAttribute("x"); 23 | var y = this.getAttribute("y"); 24 | 25 | if(imageOther != null){ 26 | 27 | for(var j=0; j= 0 && ox < imageOther.getWidth() && oy >= 0 && oy < imageOther.getHeight()){ 34 | var alpha = imageOther.getAlphaComponent(ox,oy); 35 | if(alpha != 0){ 36 | var factor = alpha/255; 37 | 38 | var rA = imageIn.getIntComponent0(i,j); 39 | var gA = imageIn.getIntComponent1(i,j); 40 | var bA = imageIn.getIntComponent2(i,j); 41 | 42 | var rB = imageOther.getIntComponent0(ox,oy); 43 | var gB = imageOther.getIntComponent1(ox,oy); 44 | var bB = imageOther.getIntComponent2(ox,oy); 45 | 46 | var red = Math.floor( (rA * (1-factor)) + (rB * (factor)) ); 47 | var green = Math.floor( (gA * (1-factor)) + (gB * (factor)) ); 48 | var blue = Math.floor( (bA * (1-factor)) + (bB * (factor)) ); 49 | 50 | imageOut.setIntColor(i,j,Math.max(imageIn.getAlphaComponent(x,y), alpha), red, green, blue); 51 | } else{ 52 | imageOut.setIntColor(i,j, imageIn.getIntColor(i,j)); 53 | } 54 | } else{ 55 | imageOut.setIntColor(i,j, imageIn.getIntColor(i,j)); 56 | } 57 | } 58 | } 59 | } 60 | }; -------------------------------------------------------------------------------- /marvinj/src/plugins/combine/MergePhotos.js: -------------------------------------------------------------------------------- 1 | function MergePhotos(){ 2 | MarvinAbstractImagePlugin.super(this); 3 | this.load(); 4 | } 5 | 6 | MergePhotos.prototype.load = function() { 7 | this.background = new DetermineSceneBackground(); 8 | this.background.load(); 9 | this.setAttribute("threshold", 30); 10 | } 11 | 12 | MergePhotos.prototype.process = function 13 | ( 14 | images, 15 | imageOut 16 | ) 17 | { 18 | if(images.length > 0){ 19 | var threshold = this.getAttribute("threshold"); 20 | this.background.setAttribute("threshold", threshold); 21 | var backgroundImage = images[0].clone(); 22 | this.background.process(images, backgroundImage); 23 | MarvinImage.copyColorArray(backgroundImage, imageOut); 24 | this.mergePhotos(images, imageOut, backgroundImage, threshold); 25 | } 26 | } 27 | 28 | MergePhotos.prototype.mergePhotos = function(images, imageOut, background, threshold){ 29 | for(var i in images){ 30 | var img = images[i]; 31 | this.mergePhotosSingle(img, imageOut, background, threshold); 32 | } 33 | } 34 | 35 | MergePhotos.prototype.mergePhotosSingle = function(imageA, imageB, imageBackground, threshold){ 36 | 37 | var rA, gA, bA, rB, gB, bB; 38 | for(var y=0; y threshold || 51 | Math.abs(gA-gB) > threshold || 52 | Math.abs(bA-bB) > threshold 53 | ){ 54 | 55 | imageB.setIntColor(x, y, 255, rA, gA, bA); 56 | } 57 | } 58 | } 59 | } 60 | 61 | -------------------------------------------------------------------------------- /marvinj/src/plugins/convolution/Convolution.js: -------------------------------------------------------------------------------- 1 | function Convolution(){ 2 | MarvinAbstractImagePlugin.super(this); 3 | this.load(); 4 | } 5 | 6 | Convolution.prototype.load = function(){ 7 | this.setAttribute("matrix", null); 8 | } 9 | 10 | Convolution.prototype.process = function 11 | ( 12 | imageIn, 13 | imageOut, 14 | attributesOut, 15 | mask, 16 | previewMode 17 | ) 18 | { 19 | var matrix = this.getAttribute("matrix"); 20 | 21 | if(matrix != null && matrix.length > 0){ 22 | 23 | for(var y=0; y= matrix.length/2 && y < imageIn.getHeight()-matrix.length/2 && x >= matrix[0].length/2 && x < imageIn.getWidth()-matrix[0].length/2){ 27 | this.applyMatrix(x, y, matrix, imageIn, imageOut); 28 | } 29 | else{ 30 | imageOut.setIntColor(x, y, 0xFF000000); 31 | } 32 | } 33 | } 34 | } 35 | }; 36 | 37 | Convolution.prototype.applyMatrix = function 38 | ( 39 | x, 40 | y, 41 | matrix, 42 | imageIn, 43 | imageOut 44 | ){ 45 | 46 | var nx,ny; 47 | var resultRed=0; 48 | var resultGreen=0; 49 | var resultBlue=0; 50 | 51 | var xC=Math.ceil(matrix[0].length/2); 52 | var yC=Math.ceil(matrix.length/2); 53 | 54 | for(var i=0; i= 0 && nx < imageOut.getWidth() && ny >= 0 && ny < imageOut.getHeight()){ 62 | 63 | resultRed += (matrix[i][j]*(imageIn.getIntComponent0(nx, ny))); 64 | resultGreen += (matrix[i][j]*(imageIn.getIntComponent1(nx, ny))); 65 | resultBlue += (matrix[i][j]*(imageIn.getIntComponent2(nx, ny))); 66 | } 67 | 68 | 69 | } 70 | 71 | 72 | 73 | } 74 | } 75 | 76 | resultRed = Math.abs(resultRed); 77 | resultGreen = Math.abs(resultGreen); 78 | resultBlue = Math.abs(resultBlue); 79 | 80 | // allow the combination of multiple applications 81 | resultRed += imageOut.getIntComponent0(x,y); 82 | resultGreen += imageOut.getIntComponent1(x,y); 83 | resultBlue += imageOut.getIntComponent2(x,y); 84 | 85 | resultRed = Math.min(resultRed, 255); 86 | resultGreen = Math.min(resultGreen, 255); 87 | resultBlue = Math.min(resultBlue, 255); 88 | 89 | resultRed = Math.max(resultRed, 0); 90 | resultGreen = Math.max(resultGreen, 0); 91 | resultBlue = Math.max(resultBlue, 0); 92 | 93 | imageOut.setIntColor(x, y, imageIn.getAlphaComponent(x, y), Math.floor(resultRed), Math.floor(resultGreen), Math.floor(resultBlue)); 94 | }; 95 | -------------------------------------------------------------------------------- /marvinj/src/plugins/corner/Moravec.js: -------------------------------------------------------------------------------- 1 | function Moravec(){ 2 | MarvinAbstractImagePlugin.super(this); 3 | this.load(); 4 | } 5 | 6 | Moravec.prototype.load = function(){ 7 | this.setAttribute("matrixSize", 3); 8 | this.setAttribute("threshold", 0); 9 | } 10 | 11 | Moravec.prototype.process = function 12 | ( 13 | imageIn, 14 | imageOut, 15 | attrOut, 16 | mask, 17 | previewMode 18 | ) 19 | { 20 | var matrixSize = this.getAttribute("matrixSize"); 21 | var threshold = this.getAttribute("threshold"); 22 | 23 | var tempImage = new MarvinImage(imageIn.getWidth(), imageIn.getHeight()); 24 | Marvin.grayScale(imageIn, tempImage); 25 | 26 | var cornernessMap = MarvinJSUtils.createMatrix2D(tempImage.getWidth(), tempImage.getHeight(), 0); 27 | var cornernessMapOut = MarvinJSUtils.createMatrix2D(tempImage.getWidth(), tempImage.getHeight(), 0); 28 | 29 | for(var y=0; y 0){ 44 | cornernessMapOut[x][y] = 1; 45 | } 46 | } 47 | } 48 | 49 | if(attrOut != null){ 50 | attrOut.set("cornernessMap", cornernessMapOut); 51 | } 52 | } 53 | 54 | Moravec.prototype.nonmax = function(x, y, matrixSize, matrix){ 55 | var s = Math.floor(matrixSize/2); 56 | if(x-(s+1) >= 0 && x+(s+1) < matrix.length && y-(s+1) >= 0 && y+(s+1) < matrix[0].length){ 57 | for(var i=-s; i<=s; i++){ 58 | for(var j=-s; j<=s; j++){ 59 | if(i != 0 || j != 0){ 60 | if(matrix[x][y] < matrix[x+i][y+j]){ 61 | return 0; 62 | } 63 | } 64 | } 65 | } 66 | } 67 | return matrix[x][y]; 68 | } 69 | 70 | Moravec.directions = [[1,0], [-1, 0], [0, 1], [0,-1], [-1,-1], [1, -1], [-1, 1], [1,1]]; 71 | 72 | Moravec.prototype.c = function(x, y, matrixSize, image){ 73 | 74 | var ret = -1; 75 | var temp; 76 | var s = Math.floor(matrixSize/2); 77 | if(x-(s+1) >= 0 && x+(s+1) < image.getWidth() && y-(s+1) >= 0 && y+(s+1) < image.getHeight()){ 78 | 79 | for(var d=0; d 0){ 54 | l_point = l_list.splice(0,1)[0]; // list poll 55 | l_pointW = new MarvinPoint(l_point.x, l_point.y); 56 | l_pointE = new MarvinPoint(l_point.x, l_point.y); 57 | 58 | // west 59 | while(true){ 60 | if(l_pointW.x-1 >= 0 && this.match(imgIn, l_pointW.x-1, l_pointW.y, targetRed, targetGreen, targetBlue, this.threshold) && !fillMask[l_pointW.x-1][l_pointW.y]){ 61 | l_pointW.x--; 62 | } 63 | else{ 64 | break; 65 | } 66 | } 67 | 68 | // east 69 | while(true){ 70 | if(l_pointE.x+1 < imgIn.getWidth() && this.match(imgIn, l_pointE.x+1, l_pointE.y, targetRed, targetGreen, targetBlue, this.threshold) && !fillMask[l_pointE.x+1][l_pointE.y]){ 71 | l_pointE.x++; 72 | } 73 | else{ 74 | break; 75 | } 76 | } 77 | 78 | // set color of pixels between pointW and pointE 79 | for(var l_px=l_pointW.x; l_px<=l_pointE.x; l_px++){ 80 | //imgOut.setIntColor(l_px, l_point.y, -1); 81 | //drawPixel(imgOut, l_px, l_point.y, newColor, tileImage); 82 | fillMask[l_px][l_point.y] = true; 83 | 84 | if(l_point.y-1 >= 0 && this.match(imgIn, l_px, l_point.y-1, targetRed, targetGreen, targetBlue, this.threshold) && !fillMask[l_px][l_point.y-1]){ 85 | l_list.push(new MarvinPoint(l_px, l_point.y-1)); 86 | } 87 | if(l_point.y+1 < imgOut.getHeight() && this.match(imgIn, l_px, l_point.y+1, targetRed, targetGreen, targetBlue, this.threshold) && !fillMask[l_px][l_point.y+1]){ 88 | l_list.push(new MarvinPoint(l_px, l_point.y+1)); 89 | } 90 | } 91 | } 92 | 93 | if(tileImage != null){ 94 | /* Plugin not ported yet. */ 95 | /* 96 | var p = MarvinPluginLoader.loadImagePlugin("org.marvinproject.image.texture.tileTexture.jar"); 97 | p.setAttribute("lines", (int)(Math.ceil((double)imgOut.getHeight()/tileImage.getHeight()))); 98 | p.setAttribute("columns", (int)(Math.ceil((double)imgOut.getWidth()/tileImage.getWidth()))); 99 | p.setAttribute("tile", tileImage); 100 | MarvinImageMask newMask = new MarvinImageMask(fillMask); 101 | p.process(imgOut, imgOut, null, newMask, false); 102 | */ 103 | } 104 | else{ 105 | for(var j=0; j this.threshold){ 38 | imageOut.setIntColor(x,y,imageIn.getAlphaComponent(x,y), 255,255,255); 39 | dif = -(255-color); 40 | } 41 | else{ 42 | imageOut.setIntColor(x,y,imageIn.getAlphaComponent(x,y), 0,0,0); 43 | dif = color; 44 | } 45 | 46 | // Pixel Right 47 | if(x+1 < imageOut.getWidth()){ 48 | color = imageOut.getIntComponent0(x+1,y); 49 | color+= Math.floor(0.4375*dif); 50 | color = this.getValidGray(color); 51 | imageOut.setIntColor(x+1,y,imageIn.getAlphaComponent(x+1,y), color,color,color); 52 | 53 | // Pixel Right Down 54 | if(y+1 < imageOut.getHeight()){ 55 | color = imageOut.getIntComponent0(x+1,y+1); 56 | color+=Math.floor(0.0625*dif); 57 | color = this.getValidGray(color); 58 | imageOut.setIntColor(x+1,y+1,imageIn.getAlphaComponent(x+1,y+1), color,color,color); 59 | } 60 | } 61 | 62 | // Pixel Down 63 | if(y+1 < imageOut.getHeight()){ 64 | color = imageOut.getIntComponent0(x,y+1); 65 | color+=Math.floor(0.3125*dif); 66 | color = this.getValidGray(color); 67 | imageOut.setIntColor(x,y+1,imageIn.getAlphaComponent(x,y+1), color,color,color); 68 | 69 | // Pixel Down Left 70 | if(x-1 >= 0){ 71 | color = imageOut.getIntComponent0(x-1,y+1); 72 | color+=Math.floor(0.1875*dif); 73 | color = this.getValidGray(color); 74 | imageOut.setIntColor(x-1,y+1,imageIn.getAlphaComponent(x-1,y+1), color,color,color); 75 | } 76 | } 77 | } 78 | } 79 | } 80 | 81 | ErrorDiffusion.prototype.getValidGray = function(a_value){ 82 | if(a_value < 0) return 0; 83 | if(a_value > 255) return 255; 84 | return a_value; 85 | } 86 | -------------------------------------------------------------------------------- /marvinj/src/plugins/morphological/Closing.js: -------------------------------------------------------------------------------- 1 | function Closing(){ 2 | MarvinAbstractImagePlugin.super(this); 3 | this.load(); 4 | } 5 | 6 | Closing.prototype.load = function(){ 7 | this.matrix = MarvinJSUtils.createMatrix2D(3,3,true); 8 | this.setAttribute("matrix",3); 9 | }; 10 | 11 | 12 | Closing.prototype.process = function 13 | ( 14 | imgIn, 15 | imgOut, 16 | attributesOut, 17 | mask, 18 | previewMode 19 | ) 20 | { 21 | var matrix = this.getAttribute("matrix"); 22 | 23 | if(imgIn.getColorModel() == MarvinImage.COLOR_MODEL_BINARY && matrix != null){ 24 | 25 | Marvin.morphologicalDilation(imgIn, imgOut, matrix); 26 | MarvinImage.copyColorArray(imgOut, imgIn); 27 | Marvin.morphologicalErosion(imgIn, imgOut, matrix); 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /marvinj/src/plugins/morphological/Dilation.js: -------------------------------------------------------------------------------- 1 | function Dilation(){ 2 | MarvinAbstractImagePlugin.super(this); 3 | this.load(); 4 | } 5 | 6 | Dilation.prototype.load = function(){ 7 | 8 | this.matrix = MarvinJSUtils.createMatrix2D(3,3,true); 9 | this.setAttribute("matrix",3); 10 | } 11 | 12 | Dilation.prototype.process = function 13 | ( 14 | imgIn, 15 | imgOut, 16 | attributesOut, 17 | mask, 18 | previewMode 19 | ) 20 | { 21 | var matrix = this.getAttribute("matrix"); 22 | 23 | if(imgIn.getColorModel() == MarvinImage.COLOR_MODEL_BINARY && matrix != null){ 24 | 25 | MarvinImage.copyColorArray(imgIn, imgOut); 26 | 27 | for(var y=0; y 0 && nx < imgOut.getWidth() && ny > 0 && ny < imgOut.getHeight()){ 58 | imgOut.setBinaryColor(nx, ny, true); 59 | } 60 | } 61 | } 62 | } 63 | } 64 | } 65 | 66 | -------------------------------------------------------------------------------- /marvinj/src/plugins/morphological/Erosion.js: -------------------------------------------------------------------------------- 1 | function Erosion(){ 2 | MarvinAbstractImagePlugin.super(this); 3 | this.load(); 4 | } 5 | 6 | Erosion.prototype.load = function(){ 7 | 8 | this.matrix = MarvinJSUtils.createMatrix2D(3,3,true); 9 | this.setAttribute("matrix",3); 10 | } 11 | 12 | Erosion.prototype.process = function 13 | ( 14 | imgIn, 15 | imgOut, 16 | attributesOut, 17 | mask, 18 | previewMode 19 | ) 20 | { 21 | var matrix = this.getAttribute("matrix"); 22 | 23 | if(imgIn.getColorModel() == MarvinImage.COLOR_MODEL_BINARY && matrix != null){ 24 | 25 | MarvinImage.copyColorArray(imgIn, imgOut); 26 | 27 | for(var y=0; y= 0 && nx < imgOut.getWidth() && ny >= 0 && ny < imgOut.getHeight()){ 59 | imgOut.setBinaryColor(nx, ny, false); 60 | } 61 | } 62 | } 63 | } 64 | } 65 | } 66 | 67 | -------------------------------------------------------------------------------- /marvinj/src/plugins/pattern/FindTextRegions.js: -------------------------------------------------------------------------------- 1 | function FindTextRegions(){ 2 | MarvinAbstractImagePlugin.super(this); 3 | this.load(); 4 | } 5 | 6 | FindTextRegions.prototype.load = function() { 7 | this.setAttribute("maxWhiteSpace", 10); 8 | this.setAttribute("maxFontLineWidth", 10); 9 | this.setAttribute("minTextWidth", 30); 10 | this.setAttribute("grayScaleThreshold", 127); 11 | } 12 | 13 | FindTextRegions.prototype.process = function 14 | ( 15 | imageIn, 16 | imageOut, 17 | attrOut, 18 | mask, 19 | previewMode 20 | ){ 21 | // The image will be affected so it's generated a new instance 22 | imageIn = imageIn.clone(); 23 | 24 | var maxWhiteSpace = this.getAttribute("maxWhiteSpace"); 25 | var maxFontLineWidth = this.getAttribute("maxFontLineWidth"); 26 | var minTextWidth = this.getAttribute("minTextWidth"); 27 | var grayScaleThreshold = this.getAttribute("grayScaleThreshold"); 28 | 29 | 30 | Marvin.thresholding(imageIn, imageIn, grayScaleThreshold); 31 | 32 | var segments = []; 33 | for(var i=0; i maxWhiteSpace || blackPixels > maxFontLineWidth || x == imageIn.getWidth()-1){ 70 | 71 | if(patternLength >= minTextWidth){ 72 | var list = segments[y]; 73 | list.push([patternStartX, y, patternStartX+patternLength, y]); 74 | } 75 | 76 | whitePixels=0; 77 | blackPixels=0; 78 | patternLength=0; 79 | patternStartX=-1; 80 | } 81 | 82 | if(patternStartX != -1){ 83 | patternLength++; 84 | } 85 | 86 | processed[x][y] = true; 87 | } 88 | } 89 | } 90 | 91 | 92 | // Group line patterns intersecting in x coordinate and too near in y coordinate. 93 | for(var y=0; y= sB[2]) || 112 | (sA[0] >= sB[0] && sA[0] <= sB[2]) || 113 | (sA[2] >= sB[0] && sA[2] <= sB[2]) 114 | 115 | ){ 116 | sA[0] = Math.min(sA[0], sB[0]); 117 | sA[2] = Math.max(sA[2], sB[2]); 118 | sA[3] = sB[3]; 119 | 120 | listY.splice(i, 1); 121 | i--; 122 | 123 | listW.splice(j, 1); 124 | listW.push(sA); 125 | 126 | break; 127 | } 128 | } 129 | } 130 | } 131 | } 132 | 133 | // Convert the result to a List<> of MarvinSegment objects. 134 | var marvinSegments = []; 135 | for(var y=0; y rules; 22 | 23 | // Testing String 24 | private final static String EXAMPLE_RULES = "0,0,0,0.16,0,0,0.01\n"+ 25 | "0.85,0.04,-0.04,0.85,0,1.6,0.85\n"+ 26 | "0.2,-0.26,0.23,0.22,0,1.6,0.07\n"+ 27 | "-0.15,0.28,0.26,0.24,0,0.44,0.07\n"; 28 | @Override 29 | public void load() { 30 | attributes = getAttributes(); 31 | attributes.set("rules", EXAMPLE_RULES); 32 | attributes.set("iterations", 1000000); 33 | 34 | rules = new ArrayList(); 35 | } 36 | */ 37 | 38 | IteratedFunctionSystem.prototype.process = function 39 | ( 40 | imageIn, 41 | imageOut, 42 | attributesOut, 43 | mask, 44 | previewMode 45 | ) 46 | { 47 | this.loadRules(); 48 | var iterations = this.getAttribute("iterations"); 49 | 50 | var x0 = 0; 51 | var y0 = 0; 52 | var x,y; 53 | var startX; 54 | var startY; 55 | var factor; 56 | 57 | var minX=999999999,minY=999999999,maxX=-999999999,maxY=-99999999; 58 | 59 | var tempRule; 60 | var point = [x0,y0]; 61 | 62 | imageOut.clear(0xFFFFFFFF); 63 | 64 | for(var i=0; i maxX){ maxX = x; }; 73 | if(y < minY){ minY = y; }; 74 | if(y > maxY){ maxY = y; }; 75 | 76 | } 77 | 78 | var width = imageOut.getWidth(); 79 | var height = imageOut.getHeight(); 80 | 81 | var deltaX = Math.abs(maxX-minX); 82 | var deltaY = Math.abs(maxY-minY); 83 | if(deltaX > deltaY){ 84 | factor = (width/deltaX); 85 | if(deltaY * factor > height){ 86 | factor = factor * (height/(deltaY * factor)); 87 | } 88 | } 89 | else{ 90 | factor = (height/deltaY); 91 | if(deltaX * factor > width){ 92 | factor = factor * (width/(deltaX * factor)); 93 | } 94 | } 95 | 96 | factor *= 0.9; 97 | 98 | startX = Math.floor(((width/2)-((minX+((deltaX)/2))*factor))); 99 | startY = Math.floor((height-((height/2)-((minY+(deltaY/2))*factor)))); 100 | 101 | point[0] = x0; 102 | point[1] = y0; 103 | 104 | for(var i=0; i= 0 && x= 0 && y < height){ 112 | imageOut.setIntColor(Math.floor(x),Math.floor(y) , 255, 0); 113 | } 114 | } 115 | } 116 | 117 | IteratedFunctionSystem.prototype.loadRules = function(){ 118 | this.rules = []; 119 | var r = this.getAttribute("rules").split("\n"); 120 | 121 | for(var i=0; i 0){ 45 | var c = 0xFF000000 | (currentColor++); 46 | Marvin.boundaryFill(image, fillBuffer, x, y, c); 47 | } 48 | } 49 | } 50 | 51 | var segments = new Array(currentColor-1); 52 | var seg; 53 | for(var y=0; y 0){ 58 | 59 | seg = segments[color-1]; 60 | 61 | if(seg == null){ 62 | seg = new MarvinSegment(); 63 | segments[color-1] = seg; 64 | } 65 | 66 | // x and width 67 | if(seg.x1 == -1 || x < seg.x1) { seg.x1 = x; } 68 | if(seg.x2 == -1 || x > seg.x2) { seg.x2 = x; } 69 | seg.width = (seg.x2-seg.x1)+1; 70 | 71 | // y and height; 72 | if(seg.y1 == -1 || y < seg.y1) { seg.y1 = y; } 73 | if(seg.y2 == -1 || y > seg.y2) { seg.y2 = y; } 74 | seg.height = (seg.y2-seg.y1)+1; 75 | 76 | seg.area++; 77 | } 78 | } 79 | } 80 | 81 | return segments; 82 | } 83 | 84 | FloodfillSegmentation.prototype.blobSegments = function(image, segments){ 85 | 86 | var blobSegments = new Array(segments.length); 87 | 88 | var colorSegment; 89 | var seg; 90 | for(var i=0; i>16) ; 38 | y2 = Math.floor((i*y_ratio)>>16) ; 39 | imageOut.setIntColor(j,i, imageIn.getAlphaComponent(x2,y2), imageIn.getIntColor(x2,y2)); 40 | } 41 | } 42 | } 43 | }; 44 | 45 | -------------------------------------------------------------------------------- /marvinj/src/util/MarvinAttributes.js: -------------------------------------------------------------------------------- 1 | function MarvinAttributes(){ 2 | this.hashAttributes = new Object(); 3 | } 4 | 5 | MarvinAttributes.prototype.set = function(name, value){ 6 | this.hashAttributes[name] = value; 7 | }; 8 | 9 | MarvinAttributes.prototype.get = function(name, defaultValue){ 10 | var ret = this.hashAttributes[name]; 11 | 12 | if(ret != null){ 13 | return ret; 14 | } 15 | return defaultValue; 16 | }; 17 | 18 | MarvinAttributes.prototype.clone = function(){ 19 | var attrs = new MarvinAttributes(); 20 | 21 | for(var key in this.hashAttributes){ 22 | attrs.set(key, this.hashAttributes[key]); 23 | } 24 | return attrs; 25 | }; -------------------------------------------------------------------------------- /marvinj/src/util/MarvinPoint.js: -------------------------------------------------------------------------------- 1 | function MarvinPoint(x,y){ 2 | this.x = x; 3 | this.y = y; 4 | } 5 | 6 | MarvinPoint.prototype.setX = function(x){ 7 | this.x = x; 8 | }; 9 | 10 | MarvinPoint.prototype.getX = function(){ 11 | return this.x; 12 | }; 13 | 14 | MarvinPoint.prototype.setY = function(x){ 15 | this.y = y; 16 | }; 17 | 18 | MarvinPoint.prototype.getY = function(){ 19 | return this.y; 20 | }; -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.lock -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.mylyn/.tasks.xml.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.mylyn/.tasks.xml.zip -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.mylyn/repositories.xml.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.mylyn/repositories.xml.zip -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.mylyn/tasks.xml.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.mylyn/tasks.xml.zip -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.resources/.projects/Builder/.markers: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.resources/.projects/Builder/.markers -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.resources/.projects/Builder/org.eclipse.jdt.core/state.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.resources/.projects/Builder/org.eclipse.jdt.core/state.dat -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index: -------------------------------------------------------------------------------- 1 | /org.eclipse.core.resourcescontentCacheState2contentCacheTimestamp 1362934655658org.eclipse.jdt.corestateVersionNumber26 -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.resources/.root/5.tree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.resources/.root/5.tree -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.runtime/.settings/com.collabnet.subversion.merge.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | merge_provider_set=true 3 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | version=1 3 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.debug.ui.PREF_LAUNCH_PERSPECTIVES=\r\n\r\n 3 | preferredTargets=default\:default| 4 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.codeComplete.visibilityCheck=enabled 3 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 5 | org.eclipse.jdt.core.compiler.compliance=1.7 6 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 7 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 8 | org.eclipse.jdt.core.compiler.source=1.7 9 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.launching.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.launching.PREF_VM_XML=\r\n\r\n\r\n\r\n\r\n\r\n 3 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs: -------------------------------------------------------------------------------- 1 | content_assist_lru_history= 2 | content_assist_number_of_computers=13 3 | content_assist_proposals_background=255,255,255 4 | content_assist_proposals_foreground=0,0,0 5 | eclipse.preferences.version=1 6 | fontPropagated=true 7 | org.eclipse.jdt.ui.editor.tab.width= 8 | org.eclipse.jdt.ui.formatterprofiles.version=12 9 | org.eclipse.jdt.ui.javadoclocations.migrated=true 10 | org.eclipse.jdt.ui.text.code_templates_migrated=true 11 | org.eclipse.jdt.ui.text.custom_code_templates= 12 | org.eclipse.jdt.ui.text.custom_templates= 13 | org.eclipse.jdt.ui.text.templates_migrated=true 14 | org.eclipse.jface.textfont=1|Consolas|10.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Consolas; 15 | proposalOrderMigrated=true 16 | spelling_locale_initialized=true 17 | tabWidthPropagated=true 18 | useAnnotationsPrefPage=true 19 | useQuickDiffPrefPage=true 20 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.m2e.discovery.pref.projects= 3 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | mylyn.attention.migrated=true 3 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.mylyn.monitor.activity.tracking.enabled.checked=true 3 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.team.ui.first_time=false 3 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | overviewRuler_migration=migrated_3.1 3 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs: -------------------------------------------------------------------------------- 1 | PROBLEMS_FILTERS_MIGRATE=true 2 | eclipse.preferences.version=1 3 | platformState=1362934655658 4 | quickStart=false 5 | tipsAndTricks=true 6 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | showIntro=false 3 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs: -------------------------------------------------------------------------------- 1 | PLUGINS_NOT_ACTIVATED_ON_STARTUP=org.eclipse.m2e.discovery; 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.tigris.subversion.subclipse.tools.usage.prefs: -------------------------------------------------------------------------------- 1 | ask_user_for_usage_report_preference=false 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.tigris.subversion.subclipse.ui.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | pref_merge_provider=CollabNet Desktop 3 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.debug.core/.launches/Builder.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/1075156909.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/1075156909.index -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/1144188029.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/1144188029.index -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/1820024274.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/1820024274.index -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/1825553220.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/1825553220.index -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/2706502329.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/2706502329.index -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/2708239607.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/2708239607.index -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/3015671029.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/3015671029.index -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/3256372620.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/3256372620.index -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/3521617142.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/3521617142.index -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/3626931047.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/3626931047.index -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/3814551627.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/3814551627.index -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/384216248.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/384216248.index -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/4018706093.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/4018706093.index -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/4149142647.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/4149142647.index -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/683184654.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/683184654.index -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/728132027.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/728132027.index -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/739078005.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/739078005.index -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/externalLibsTimeStamps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/externalLibsTimeStamps -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/invalidArchivesCache: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt: -------------------------------------------------------------------------------- 1 | java -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache: -------------------------------------------------------------------------------- 1 | /Builder/lib/commons-io-2.4.jar -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt: -------------------------------------------------------------------------------- 1 | INDEX VERSION 1.126+C:\Users\Gabriel\Documents\Projetos\Pessoais\Java\j2se\MARVIN\git\marvinj\tools\builder\.metadata\.plugins\org.eclipse.jdt.core 2 | 1825553220.index 3 | 3521617142.index 4 | 683184654.index 5 | 1144188029.index 6 | 4149142647.index 7 | 4018706093.index 8 | 2706502329.index 9 | 2708239607.index 10 | 3256372620.index 11 | 739078005.index 12 | 384216248.index 13 | 3814551627.index 14 | 3015671029.index 15 | 1075156909.index 16 | 728132027.index 17 | 1820024274.index 18 | 3626931047.index 19 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.launching/libraryInfos.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 |
16 |
17 |
18 |
19 | 20 |
21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |
34 |
35 |
36 |
37 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.4.0.20130601-0317.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %date [%thread] %-5level %logger{35} - %msg%n 5 | 6 | 7 | 8 | 9 | 10 | ${org.eclipse.m2e.log.dir}/0.log 11 | 12 | ${org.eclipse.m2e.log.dir}/%i.log 13 | 1 14 | 10 15 | 16 | 17 | 100MB 18 | 19 | 20 | %date [%thread] %-5level %logger{35} - %msg%n 21 | 22 | 23 | 24 | 25 | 26 | WARN 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 | 5 | 6 | 7 | 8 |
9 |
10 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/.plugins/org.tigris.subversion.subclipse.ui/dialog_settings.xml: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 | -------------------------------------------------------------------------------- /marvinj/tools/builder/.metadata/version.ini: -------------------------------------------------------------------------------- 1 | org.eclipse.core.runtime=1 -------------------------------------------------------------------------------- /marvinj/tools/builder/Builder/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /marvinj/tools/builder/Builder/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Builder 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /marvinj/tools/builder/Builder/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.7 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.source=1.7 12 | -------------------------------------------------------------------------------- /marvinj/tools/builder/Builder/lib/commons-io-2.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielarchanjo/marvinj/b758c84e6a3c13b1dd8d13d052e42a2e6331b609/marvinj/tools/builder/Builder/lib/commons-io-2.4.jar -------------------------------------------------------------------------------- /marvinj/tools/builder/Builder/src/Builder.java: -------------------------------------------------------------------------------- 1 | import java.io.File; 2 | import java.io.IOException; 3 | 4 | import javax.swing.filechooser.FileNameExtensionFilter; 5 | 6 | import org.apache.commons.io.FileUtils; 7 | import org.apache.commons.io.FilenameUtils; 8 | 9 | 10 | public class Builder { 11 | 12 | public Builder(String path){ 13 | 14 | StringBuilder finalContent = new StringBuilder(); 15 | 16 | try { 17 | File rootPath = new File(path); 18 | appendFiles(rootPath, finalContent); 19 | finalContent.append(FileUtils.readFileToString(new File(rootPath.getAbsoluteFile()+"\\MarvinFramework.js"))); 20 | File fileOut = new File("./marvinjs-x.y.js"); 21 | FileUtils.write(fileOut, finalContent); 22 | } catch (IOException e) { 23 | e.printStackTrace(); 24 | } 25 | } 26 | 27 | private void appendFiles(File dir, StringBuilder finalContent) throws IOException{ 28 | 29 | File[] files = dir.listFiles(); 30 | 31 | for(File f:files){ 32 | if(f.isDirectory()){ 33 | appendFiles(f, finalContent); 34 | } 35 | else if(FilenameUtils.getExtension(f.getName()).equals("js") && !f.getName().equals("MarvinFramework.js")){ 36 | String content = FileUtils.readFileToString(f); 37 | finalContent.append("\n"); 38 | finalContent.append(content); 39 | } 40 | } 41 | } 42 | 43 | public static void main(String args[]){ 44 | new Builder(args[0]); 45 | System.exit(0); 46 | } 47 | } 48 | 49 | 50 | --------------------------------------------------------------------------------