Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Oct 1, 2010, 11:54 AM   #1
Blakeasd
macrumors 6502a
 
Join Date: Dec 2009
Core Image

Does anyone know of a good Core Image tutorial? If you do please tell me. Thanks, Blake

Last edited by Blakeasd; Oct 6, 2010 at 09:30 PM.
Blakeasd is offline   0 Reply With Quote
Old Oct 1, 2010, 03:21 PM   #2
chown33
macrumors 603
 
Join Date: Aug 2009
Describe your level of experience in graphics processing, specifically digital image filtering.

I easily found suitable articles with the following search terms:
core image tutorial site:developer.apple.com
One is even titled "Image Unit Tutorial".

If those are unsuitable for you, then you'll have to explain what types of tutorials would be suitable, by summarizing your current level of graphics processing knowledge. I also suggest describing what your goal is: a single goal of creating a specific filter is different from becoming more skilled at all aspects of image processing, and combining existing filters differs from creating your own filters.
chown33 is offline   0 Reply With Quote
Old Oct 1, 2010, 05:12 PM   #3
Blakeasd
Thread Starter
macrumors 6502a
 
Join Date: Dec 2009
For my Core Image purposes I would just like to be a able to change the appearance of images for example. I would like to have a button that says motion blur. When it is clicked it takes my NSImage and applies the motion blur effect, do you know of any tutorial on how to do this using Obj-c and Cocoa (QuartzCore as well)
Thanks
Blakeasd is offline   0 Reply With Quote
Old Oct 2, 2010, 06:10 AM   #4
MorphingDragon
Banned
 
Join Date: Mar 2009
Location: The World Inbetween
Send a message via Skype™ to MorphingDragon
Quote:
Originally Posted by Blakeasd View Post
For my Core Image purposes I would just like to be a able to change the appearance of images for example. I would like to have a button that says motion blur. When it is clicked it takes my NSImage and applies the motion blur effect, do you know of any tutorial on how to do this using Obj-c and Cocoa (QuartzCore as well)
Thanks
Thats done through CoreImage too and there's an image section at the back of one of the tutorials by Apple.
MorphingDragon is offline   0 Reply With Quote
Old Oct 2, 2010, 03:03 PM   #5
Blakeasd
Thread Starter
macrumors 6502a
 
Join Date: Dec 2009
Non-Apple Sources

Does anyone know of tutorials that are not made by Apple. I have seen those and they have not provided the proper information.
Blakeasd is offline   0 Reply With Quote
Old Oct 2, 2010, 03:30 PM   #6
jared_kipe
macrumors 68030
 
jared_kipe's Avatar
 
Join Date: Dec 2003
Location: Seattle
Send a message via AIM to jared_kipe
Quote:
Originally Posted by Blakeasd View Post
... they have not provided the proper information.
I think you mean..
They have not provided you with a code snippet you can cut and paste into your application and connect to a button?
jared_kipe is offline   0 Reply With Quote
Old Oct 2, 2010, 07:21 PM   #7
Blakeasd
Thread Starter
macrumors 6502a
 
Join Date: Dec 2009
No that's actually not what I mean...... Maybe I just don't like the way Apple Documentation is organized...... Some people are so ignorant because they have more experience in something. Instead of making snobby remarks perhaps it is best for you to use a more constructive response such as "I think you should read Apple Documentation as it provides more in-depth information on the subject". That is what a mature individual would say.
Blakeasd is offline   0 Reply With Quote
Old Oct 2, 2010, 07:26 PM   #8
NT1440
macrumors G3
 
NT1440's Avatar
 
Join Date: May 2008
Location: Hartford, CT
Quote:
Originally Posted by Blakeasd View Post
No that's actually not what I mean...... Maybe I just don't like the way Apple Documentation is organized...... Some people are so ignorant because they have more experience in something. Instead of making snobby remarks perhaps it is best for you to use a more constructive response such as "I think you should read Apple Documentation as it provides more in-depth information on the subject". That is what a mature individual would say.
Well, that's one sure fire way to eliminate the chances of anyone helping you...
NT1440 is offline   0 Reply With Quote
Old Oct 2, 2010, 08:23 PM   #9
Blakeasd
Thread Starter
macrumors 6502a
 
Join Date: Dec 2009
Whenever I go on this forum I find a bunch of ignorant people. No one gets any help on this forum anyway. Instead people asking questions get a bunch of crap from some snobs. I can go to Apple's forums and everyone is very helpful. Im not sure why i'm even posting here anymore...
Blakeasd is offline   0 Reply With Quote
Old Oct 2, 2010, 08:52 PM   #10
jared_kipe
macrumors 68030
 
jared_kipe's Avatar
 
Join Date: Dec 2003
Location: Seattle
Send a message via AIM to jared_kipe
Quote:
Originally Posted by Blakeasd View Post
... ignorant because they have more experience in something. ...
I think you mean..
Arrogant, because how can having more experience make you ignorant?
jared_kipe is offline   0 Reply With Quote
Old Oct 2, 2010, 09:11 PM   #11
robvas
macrumors 68000
 
Join Date: Mar 2009
Location: USA
What are the Apple examples lacking?

What is, or isn't happening when you try to integrate that code into your project? There are plenty of people here who wouldn't mind helping out if they saw the specific problem you are having.
robvas is offline   0 Reply With Quote
Old Oct 2, 2010, 09:48 PM   #12
jared_kipe
macrumors 68030
 
jared_kipe's Avatar
 
Join Date: Dec 2003
Location: Seattle
Send a message via AIM to jared_kipe
Well then, I do love a good mystery. Especially when someone cannot figure out Apple's documentation themselves.

- Keep in mind before today I have NEVER looked at the documentation, nor have ever had any experience, in Core Image.


First things first, I googled it and found this page.
http://developer.apple.com/macosx/coreimage.html
About a third of the way down the page is a code snippet as follows.
Code:
NSURL *url; 
CIImage *source;
CIImage *result;
CIFilter *hueAdjust;

url = [NSURL fileURLWithPath:path];
source = [CIImage imageWithContentsOfURL:url];

hueAdjust = [CIFilter filterWithName:@"CIHueAdjust"];
[hueAdjust setValue:source forKey:@"inputImage"];
[hueAdjust setValue:[NSNumber numberWithFloat:2.094] forKey:@"inputAngle"];

result = [hueAdjust valueForKey:@"outputImage"];
Ah ha! I thought to myself, it appears that if we knew the name of the supposed "motion blur" filter and keys that it used to modify that blur then it should be trivial to implement. I opened Xcode, typed in CIFilter and option+doubleclicked it to bring up this Apple documentation (which I used for the rest of my little exercise)
http://developer.apple.com/library/m...Reference.html


I wrote a little foundation program that goes like this..
Code:
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>

int main (int argc, const char * argv[]) {
	NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
	
	NSArray *filters = [CIFilter filterNamesInCategories: nil];
	for (id obj in filters) {
		NSLog(@"%@", obj);
	}
	[pool drain];
	return 0;
}
That listed out a LONG list of things, but it was apparent from the naming convention where to look and I quickly found "CIMotionBlur".

So I modified my program to contain ..
Code:
	CIFilter *motionBlur = [CIFilter filterWithName: @"CIMotionBlur"];
	NSDictionary *attributsDict = [motionBlur attributes];
	NSArray *keysArray = [attributsDict allKeys];
	for (id obj in keysArray) {
		NSLog(@"%@", obj);
	}
This spit out..
CIAttributeFilterDisplayName
outputImage
inputAngle
inputImage
CIAttributeFilterName
CIAttributeDescription
CIAttributeReferenceDocumentation
CIAttributeFilterCategories
inputRadius


I underlined what I feel are the important keys. I do hope that this helps you out, and that we can go on to become best friends.
jared_kipe is offline   0 Reply With Quote
Old Oct 2, 2010, 10:03 PM   #13
Blakeasd
Thread Starter
macrumors 6502a
 
Join Date: Dec 2009
Thanks! Lol i was just frustrated with not being able to figure this out, so I do apologize for my rude comments. But there is just one more thing.. How do I apply the filter to my image.(view is the name of my image by the way) I tried [view CIMotionBlur]; in hopes that that would work however it did not. So is it possible to apply the filter with in a Cocoa program?
Blakeasd is offline   0 Reply With Quote
Old Oct 2, 2010, 11:21 PM   #14
jared_kipe
macrumors 68030
 
jared_kipe's Avatar
 
Join Date: Dec 2003
Location: Seattle
Send a message via AIM to jared_kipe
Quote:
Originally Posted by Blakeasd View Post
... (view is the name of my image by the way) I tried [view CIMotionBlur]; in hopes that that would work however it did not. So is it possible to apply the filter with in a Cocoa program?
*Sigh*

Ok, firstly, that single line of code demonstrates a quite remarkable lack of grasping the core concepts here.

Secondly, yes of course it is possible in Cocoa. That question demonstrates another odd gap in what I would consider "core concepts".

Thirdly, look at the very first code fragment. Follow it through line for line and try to figure out what it is doing and what you expect is the "state" of the CIImage pointer "result" after the last line. IF you can see what is going on, THEN it should be trivial to implement a motion blur instead of hue adjustment. ELSE, you need to work on some simpler tasks before jumping into Core Image (or Cocoa more likely).
jared_kipe is offline   0 Reply With Quote
Old Oct 16, 2010, 02:22 AM   #15
Pixelmatortutor
macrumors newbie
 
Join Date: Oct 2010
Hi,

I thought that this would be a good place to start.
I started experimenting with Quartz Composer for image filter creation a few months ago, and have become a lot better through some study and some trial and error.

In certain cases I found that using the existing patches were somewhat limiting, so I decided to look into programing patches. I must admit that the Apple developer website is not the easiest of places to navigate around.

I have found a good reference guide to OpenGL shading language, but so far I have not found a good reference guide to core image kernel language.

I can get to know the commands after some studying.

Examples are all well and good, but I need to grasp the syntax or "Grammar" of the language.

I would appreciate any guidance as to the best way to learn this, and if there are any guides to this apart from the apple website.

This is like being back at school!

Many Thanks.
Pixelmatortutor is offline   0 Reply With Quote
Old Jun 8, 2011, 05:34 AM   #16
lpetrich
macrumors newbie
 
Join Date: Nov 2009
Apple's documentation has that: Core Image Kernel Language Reference: Core Image Kernel Language.

Needless to say, Apple also has Core Image Programming Guide: Introduction to Core Image Programming Guide and Core Image Programming Guide: Creating Custom Filters.

You can test your kernel code in Quartz Composer using the filter Core Image Filter. Do cmd-I on it, go the the second item in the top popup menu, and you'll get a place to enter your filter source code.

I've actually written a custom-filter kernel, one that makes rosette-group or kaleidoscope patterns:
Code:
const float PI = 3.14159265358979323846;
const float TWO_PI = 2.0*PI;

kernel vec4 Rosette(sampler Image, vec2 Center, float Angle, float Number, float Reflect)
{
    float TrueAngle = TWO_PI*Angle;
    float ReptAngle = TWO_PI/Number;
    float InvReptAngle = Number/TWO_PI;
    vec2 Pos = samplerCoord(Image) - Center;
    float PosLength = length(Pos);
    float PosAngle = atan(Pos.y, Pos.x) - TrueAngle;
    float RedPosAngle = mod(PosAngle* InvReptAngle,1.0);
    RedPosAngle = compare(-Reflect, compare(0.5-RedPosAngle, 1.0-RedPosAngle, RedPosAngle), RedPosAngle);
    PosAngle = RedPosAngle*ReptAngle;
    Pos = PosLength*cossin(PosAngle + TrueAngle) + Center;
    return sample(Image, Pos);
}
I've been meaning to do more, but I'd have to complete writing a self-contained version of that filter (kernel + info files). I'd have to see what sort of ROI setup it would need, for instance.

My experience so far:

The CI kernel has a float data type, but no others primitive ones. No booleans, characters, integers, or doubles. It's picky about numerical constants -- you have to write them as floats, even if they are integers: 1. or 1.0 instead of 1

But it does have some ways of grouping data: fixed-size arrays, structs, and vec2, vec3, and vec4 of floats.

I used not only some GLSL functions: length, atan, mod, etc., but also some CI ones: cossin, etc. One can also define one's own functions in it, and forward-declare them with prototype statements in ANSI-C/C++ fashion. However, I've had to define pi explicitly.

One can use a few C++ constructions, like const for constant values, and one can use both /* */ and // for comments.

Flow of control is very limited. One can only use if, for, do, and while statements if their control-statement outcomes can be determined at compile time, not at run time.

That may be why the CI kernel functions include compare(), defined as

compare(x,y,z) = x < 0 ? y : z

One can nest these functions; it seems that it calculates all the arg values, then does a conditional assignment.
lpetrich is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Possible to access Origional image file from texted image? (to view metadata) inck243 iPhone Tips, Help and Troubleshooting 2 Dec 8, 2013 12:47 AM
capture overlay image whenever image move new position or new scale karthees iPhone/iPad Programming 1 Mar 27, 2013 02:38 PM
Mid 2007 iMac CPU upgrade: Core 2 Duo to Core 2 Extreme or Core 2 Quad Hexley iMac 2 Dec 9, 2012 10:56 AM
Core animation image not drawn ramy1989 Mac Programming 0 Dec 2, 2012 10:54 AM
One core, dual core, quad core? Whats A6? Sensamic iPhone 49 Sep 13, 2012 04:59 PM

Forum Jump

All times are GMT -5. The time now is 02:55 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC