rgb_image's Introduction
{\rtf1\mac\ansicpg10000\cocoartf102 {\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;\f1\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;\red0\green0\blue255;\red255\green0\blue0;\red0\green255\blue0; } \vieww14820\viewh15980\viewkind0 \pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural \f0\b\fs36 \cf0 RGB Image\ \ \pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural \f1\b0\fs24 \cf0 This sample demonstrates the use of compositing to separate an NSimage\cf2 \cf0 into its \cf3 red\cf0 , \cf4 green\cf0 , and \cf2 blue\cf0 components, and shows the results of recombining those components.\ \ The conventional way to separate an RGBA image into its components would be to obtain a pointer to the pixel data, and manually separate the bytes. I started down that path when I began this sample, and then realized that that was far more work than is necessary, and would also limit the separation code to RGBA images.\ \ By using the compositing operators instead of manual data munging, we're able to separate the color components of any image, whether or not it started out as an RGB data source.\ \ Most of the interesting work in this app is done in two categories of NSImage, the TintedImage category (lifted directly from the Tinted Image sample at http://developer.apple.com/samplecode/, and the ColorSeparation category.\ \ To separate a given color (red, for example) from the original image, I create a new image, on which I composite the complementary color (cyan) over the original image using the NSCompositePlusDarker operator. The effect of this is to zero out the blue and green components, leaving the red values. To get the blue and green values, I use the same process using magenta and yellow, respectively.\ \ Another approach to separating images into their components would be to separate the pixel data manually, but by using compositing, I can get the results I want regardless of the format of the original image. In an earlier version of this sample, I was unmeshing the bytes in the RGB pixels manually, when I realized that by doing far more work, I was limiting myself to handling only one source data format! \ \ So, let's walk through the code:\ \ \f0\b RGBAppController.[hm]\ \f1\b0 \ This class is responsible for user interaction, and keeping the image views up to date. It's implemented in three parts, with code for copy/paste operations and file handling in separate files. \ \ \f0\b FileHandling.[hm]\ \f1\b0 \ This category of RGBAppController contains the methods to handle the standard Open and Save panels.\ \ \f0\b PasteboardHandling.[hm]\ \f1\b0 \ The methods in these files deal with copying an image to and from the default pasteboard. \ \ \f0\b NSImageColorSeparation.[hm]\ \f1\b0 \ These files implement two categories of NSImage, which use compositing to divide an image into its component colors.\ \ \f0\b TintedImage.[hm]\ \ \f1\b0 This code is taken directly from the Tinted Image example, available at the Apple DTS web site. It provides a method to composite an image with a color, using any of the available compositing operators.}
rgb_image's People
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.