Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Blakeasd

macrumors 6502a
Original poster
Dec 29, 2009
643
0
Does anyone know of a good Core Image tutorial? If you do please tell me. Thanks, Blake
 

chown33

Moderator
Staff member
Aug 9, 2009
10,706
8,346
A sea of green
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.
 

Blakeasd

macrumors 6502a
Original poster
Dec 29, 2009
643
0
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
 

MorphingDragon

macrumors 603
Mar 27, 2009
5,160
6
The World Inbetween
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.
 

Blakeasd

macrumors 6502a
Original poster
Dec 29, 2009
643
0
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

macrumors 6502a
Original poster
Dec 29, 2009
643
0
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.
 

NT1440

macrumors G5
May 18, 2008
14,481
20,420
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...
 

Blakeasd

macrumors 6502a
Original poster
Dec 29, 2009
643
0
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:mad:. I can go to Apple's forums and everyone is very helpful. Im not sure why i'm even posting here anymore...
 

robvas

macrumors 68040
Mar 29, 2009
3,240
629
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.
 

jared_kipe

macrumors 68030
Dec 8, 2003
2,967
1
Seattle
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/...asses/CIFilter_Class/Reference/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.
 

Blakeasd

macrumors 6502a
Original poster
Dec 29, 2009
643
0
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?
 

jared_kipe

macrumors 68030
Dec 8, 2003
2,967
1
Seattle
... (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).
 

Pixelmatortutor

macrumors newbie
Oct 15, 2010
1
0
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.
 

lpetrich

macrumors member
Nov 26, 2009
39
0
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.